python
沙扬娜拉!!!
一名想要在博客默默偷师的女程序员
展开
-
1.2闭包和装饰器
def func(): nonlocal n n=100 #局部变量 list1=[9,7,3,4,5] def inner_func(): #对list1进行+5操作 for index,i in enumerate(list1): #单纯遍历不能改变数值,enumerate可以 list1[index]=i+n #内部函数可以访问外部函数的变量 list1.sort() n+.原创 2021-04-20 19:02:21 · 70 阅读 · 0 评论 -
1.1函数的参数和变量的作用域
'''集合 列表 元组 集合无序不重复的序列,跟下标相关的不能用 enumerate 封装到元组里面,有顺序了 自己封装函数 ''' # def enumerate(value): # list1 = [] # index = 0 # for i in value: # t1 = (index, i) # list1.append(t1) # index += 1 # print(list1) # s = {1, .原创 2021-04-19 22:56:53 · 113 阅读 · 0 评论