摘要: a = 2 def wrapper(): a += 1 print(a) wrapper() 局部变量不能修改全局变量 阅读全文
posted @ 2020-05-10 22:01 岛主d 阅读(309) 评论(0) 推荐(0) 编辑
摘要: def func2(): print(2) def func3(): print(6) print(4) func3() print(8) print(3) func2() print(5) 结果: 3 2 4 6 8 5 阅读全文
posted @ 2020-05-10 18:17 岛主d 阅读(284) 评论(0) 推荐(0) 编辑
摘要: def func(*args,**kwargs): print(args,kwargs) func(1,2,3,'hhh',name = 'cbb') (1, 2, 3, 'hhh') {'name': 'cbb'} 函数内,调用: def func(*args): print(args) list 阅读全文
posted @ 2020-05-10 16:42 岛主d 阅读(222) 评论(0) 推荐(0) 编辑
摘要: def func(*argvs): number = 0 for i in argvs: number += i return number print(func(1,2,3,4)) 阅读全文
posted @ 2020-05-10 12:28 岛主d 阅读(206) 评论(0) 推荐(0) 编辑
摘要: def register(name,sex,age,edu): with open('student_msg.txt','a') as f1: f1.write(f'{name},{sex},{age},{edu}\n') n,s,a,e = input('输入姓名、性别、年龄、学历,并以逗号隔开' 阅读全文
posted @ 2020-05-10 00:19 岛主d 阅读(819) 评论(0) 推荐(0) 编辑