Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 我能';python生成器中的t回调_Python 3.x_Callback - Fatal编程技术网

Python 3.x 我能';python生成器中的t回调

Python 3.x 我能';python生成器中的t回调,python-3.x,callback,Python 3.x,Callback,我无法在方法\uuuu new\uuuu中回调,代码绕过了行返回回调('hello')。为什么? A类(对象): 定义新(cls,回调): 返回回调('hello') B类: def start1(自): 产生A(自启动2) def start2(自动,右): 产量r 生成器=B().start1() 对于g in发电机: 印刷品(g) 我怎样才能让它工作 即使将return callback('hello')替换为yield from callback('hello')也不起作用。(我使用的

我无法在方法
\uuuu new\uuuu
中回调,代码绕过了行
返回回调('hello')
。为什么?

A类(对象):
定义新(cls,回调):
返回回调('hello')
B类:
def start1(自):
产生A(自启动2)
def start2(自动,右):
产量r
生成器=B().start1()
对于g in发电机:
印刷品(g)
我怎样才能让它工作


即使将
return callback('hello')
替换为
yield from callback('hello')
也不起作用。(我使用的是python 3.7.4)

“我不能回调”不是很好的描述——预期结果是什么,实际结果是什么?是否有错误、错误的输出、无限循环?您的意思是打印(g.start3())?@PatrickHaugh是的,这很好,但我编辑帖子是因为我编写了正确的函数。你知道怎么解决吗?@kaya3我编辑了这篇文章。请现在试试密码