随笔分类 -  python

摘要:1 字符串,数字,元组 不可变,改变变量值,内存地址改变 2 列表,字典,可变,操作不会改变地址 3 字典的key 只能用不可变类型(因为py对 key 进行hash ,可变类型不能hash) ##列表操作>>> list=["a",1,2,"b"] >>> id(list) 14038619452 阅读全文
posted @ 2020-06-09 23:51 abel2020 阅读(164) 评论(0) 推荐(0)
摘要:def fun(): s="python" print("%s address is %d" % (s,id(s))) return s f=fun() print("%s address is %d" % (f,id(f))) 运行结果: python address is 30498557801 阅读全文
posted @ 2020-06-09 23:01 abel2020 阅读(263) 评论(0) 推荐(0)
摘要:a=10 print("%d address is %d" % (a,id(a))) def fun(num): print("%d address is %d" % (num,id(num))) fun(a) 运行结果: 10 address is 140706134913584 10 addre 阅读全文
posted @ 2020-06-09 22:46 abel2020 阅读(120) 评论(0) 推荐(0)
摘要:a=1 print("a address is ",id(a)) b=a c=b print("b address is ",id(b)) print("c address is ",id(c)) 打印结果: a address is 140706134913296 #b c a 都指向 1 所在的 阅读全文
posted @ 2020-06-09 22:32 abel2020 阅读(96) 评论(0) 推荐(0)
摘要:************************************************** 欢迎使用 名片管理系统 0. 退出 1. 新建名片 2. 显示全部 3. 查询名片**************************************************请选择:1您选的 阅读全文
posted @ 2020-06-09 18:37 abel2020 阅读(119) 评论(0) 推荐(0)
摘要:''' 我的第一个py小程序 名片处理系统 2020 06 09 main.py ''' #导入功能模块,单词处理每一部分功能 import cards_fun1 while True: #欢迎页面 cards_fun1.hy() # 请用户选择 num_input = input("请选择:") 阅读全文
posted @ 2020-06-09 18:30 abel2020 阅读(303) 评论(0) 推荐(0)
摘要:""" test1.py 注意缩进!! """ def pt_line(char,times,num): row=0 while row<num: print(char * times) row+=1 name ="my first module:" """ test2.py """ import 阅读全文
posted @ 2020-06-08 03:52 abel2020 阅读(104) 评论(0) 推荐(0)
摘要:def pt_line(c,times): #形参 print(c*times) times=5 char="*" row=0 while row<5: pt_line(char,times) # char ,times 实参 row+=1 循环里面的pt_line 执行时,传递参数进入第一行执行, 阅读全文
posted @ 2020-06-08 02:43 abel2020 阅读(89) 评论(0) 推荐(0)
摘要:py 根据缩进确定if 或者while 的范围 while 后面不用括号 ,使用分号 默认print 自动回车,如果不需要回车加上 ,end="" 不支持 i++ i=1;j=1 while i<=9: j=i while j<=9: print("%dX%d=%d "%(i,j,i*j),end= 阅读全文
posted @ 2020-06-08 01:41 abel2020 阅读(235) 评论(0) 推荐(0)
摘要:>>> name=input("input name:") input name:Li ming >>> sex=bool(input("input sex(True,False):")) input sex(True,False):True >>> scale=float(input("input 阅读全文
posted @ 2020-06-07 22:11 abel2020 阅读(110) 评论(0) 推荐(0)
摘要:>>> name=input("input name:") // " " 里面是提示内容,函数返回输入的内容,赋值给变量 input name:lili >>> sex=input("input sex(True,False):") input sex(True,False):False >>> a 阅读全文
posted @ 2020-06-07 21:32 abel2020 阅读(306) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-06-07 20:39 abel2020 阅读(110) 评论(0) 推荐(0)
摘要:''' these are comments my first py prog ''' print("math copute: \n") a=2 b=3 c=a+bd=a**b #### " " 里面原样输出, 多个输出 用 , ############# print("a =",a,", b =" 阅读全文
posted @ 2020-06-07 20:06 abel2020 阅读(197) 评论(0) 推荐(0)