十三. Python基础(13)--生成器进阶 1 ● send()方法 generator.send(value) Resumes the execution, and "sends" a argument which becomes the result of the current yield expression in the generator function. The send() method, like __next__(), returns the next v…
Python中的变量有两个特点: 1. 无需声明 a = 1 2. 不与类型绑定 a = 1 a = 'hello world' 变量名只是内存中具体对象的一个引用(reference). 对于 a = 1,内存模型如下: 对于 a = 1 b = a 内存模型如下: 可以通过id(x)获取变量x所引用对象的内存地址 a = 1 b = a print('address of the object referenced by a:', id(a)) print('address of the o…