Python之第二十三天的努力--函数总结
01 函数总结
# 仅限关键字参数 # def func(a,b,*args,c): # print(a,b) # print(c) # # func(1,2,3,4,c=666) # * # a,b = (1,2) # a,b,*c = (1,2,3,4,5,6) # print(a,b,c) # 1 2 [3, 4, 5, 6] # a,*b,c = [11,22,33,44,55,66,77] # print(a,b,c) # 11 [22, 33, 44, 55, 66] 77 # a,*b,c = range(10) # print(a,b,c) # 0 [1, 2, 3, 4, 5, 6, 7, 8] 9 # def func(): # global name # name = ‘zs‘ # # print(name) # 报错 # func() # print(name) # zs # name = ‘kk‘ # def func(): # global name # name = ‘zs‘ # # print(name) # kk # func() # print(name) # zs # def func(): # name = ‘zs‘ # def inner(): # nonlocal name # name = ‘kk‘ # print(name) # zs # inner() # print(name) # kk # # func() # def wrapper(a): # name = ‘zs‘ # def inner(): # print(a) # print(name) # return inner # ret = wrapper(‘kk‘) # print(ret.__code__.co_freevars) # (‘a‘, ‘name‘)
思维导图,见day14文件夹。
相关推荐
夜斗不是神 2020-11-17
huavhuahua 2020-11-20
Yasin 2020-11-16
xiaoseyihe 2020-11-16
千锋 2020-11-15
diyanpython 2020-11-12
chunjiekid 2020-11-10
wordmhg 2020-11-06
世事一场大梦 2020-11-17
xiaoseyihe 2020-11-16
Morelia 2020-11-03
CloudXli 2020-11-03
文山羊 2020-10-31
comtop0 2020-10-31
pythonxuexi 2020-10-30
三石 2020-10-29
chaochao 2020-10-27
PythonMaker 2020-10-27