函数中global和 nonlocal
都是将函数里的局部变量提升至全局变量
global直接用
nonlocal用于闭包函数
什么是闭包函数
举例:
def fun1(x):
def fun2(y):
return x*y
return fun2
函数fun2中使用了去fun1中的x,这时fun2为闭包函数
不能直接调用fun2,报错
调用fun1
fun1(5)(6)
30
使用nonlocal

lambda 匿名函数

字典
键值对应
dict = {“a”:1,“b”:2}
print(“zz”,dict1[“a”])
zz 1

新增,修改字典
