1. 首页
  2. 数据库
  3. 其它
  4. TypeError: can’t send non None value to a just started generator python报错问题

TypeError: can’t send non None value to a just started generator python报错问题

上传者: 2020-12-23 04:12:48上传 PDF文件 57.24KB 热度 18次
TypeError: can’t send non-None value to a just-started generator 翻译过来是: TypeError:无法将非None值发送到刚启动的生成器 原因如下: 在一个生成器函数未启动之前,是不能传递数值进去。必须先传递一个None进去或者调用一次next(g)方法,才能进行传值操作。 例如: 代码: def generator_two(): while True: x = yield print("value:", x) #g为上面的生成器 g = generator_two() #程序运行到yi
下载地址
用户评论