摘要:
1 局部变量各函数内部互不影响 2 函数内部与全部变量重名,局部的值有效 (同c) 3 如果需要修改全局变量: 加global , 所有受影响的地方会颜色一致凸显 阅读全文
摘要:
1 字符串,数字,元组 不可变,改变变量值,内存地址改变 2 列表,字典,可变,操作不会改变地址 3 字典的key 只能用不可变类型(因为py对 key 进行hash ,可变类型不能hash) ##列表操作>>> list=["a",1,2,"b"] >>> id(list) 14038619452 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 所在的 阅读全文
摘要:
************************************************** 欢迎使用 名片管理系统 0. 退出 1. 新建名片 2. 显示全部 3. 查询名片**************************************************请选择:1您选的 阅读全文
摘要:
''' 我的第一个py小程序 名片处理系统 2020 06 09 main.py ''' #导入功能模块,单词处理每一部分功能 import cards_fun1 while True: #欢迎页面 cards_fun1.hy() # 请用户选择 num_input = input("请选择:") 阅读全文
摘要:
""" 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 阅读全文
摘要:
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 执行时,传递参数进入第一行执行, 阅读全文
摘要:
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= 阅读全文