01 去年内容回顾
01 去年内容回顾
*args **kwargs: 万能参数,动态参数
* 魔性用法:
函数的定义时,* ** 聚合。
函数的执行时,* ** 打散。
形参顺序:
位置参数,*args,默认参数,**kwargs
名称空间:
临时名称空间:
内置名称空间:
作用域:
全局作用域:内置名称空间,全局名称空间。 # 全局作用域: 内置名称空间,全局名称空间
全局作用域:内置名称
局部作用域:临时名称空间(局部名称空间)。 # 局部作用域 : 临时名称空间 (局部名称空间)
加载顺序: 内置名称空间 全局名称空间 临时名称空间
加载顺序:内置名称空间 全局名称空间 临时名称空间
取值顺序 就近原则 LEGB
取值顺序:就近原则,LEGB。
内置函数:
globals(): 返回一个字典:全局作用域的内容。
globals(): 返回一个字典:全局作用域的内容
locals() : 返回一个字典:当前作用域的内容。
关键字:
global:
在局部作用域可以申明一个全局变量
在局部作用域可以对全局变量进行修改
1,在局部作用域可以声明一个全局变量。
2,在局部作用域可以对全局变量进行修改。
nonlocal:
不能对全局作用域进行修改
子级对父级的函数进行修改
1,不能对全局变量进行修改。
2,子级对父级函数的变量的修改。
02 作业讲解
03 函数名的运用
04 闭包
05 迭代器