如何获取foo从线程目标返回的值?
from threading import Thread
def foo(bar):
print('hello {}'.format(bar))
return 'foo'
thread = Thread(target=foo, args=('world!',))
thread.start()
return_value = thread.join()
Run Code Online (Sandbox Code Playgroud)
如上所示,"一种显而易见的方法"不起作用:'foo'返回'foo'.
我如何让一个线程将一个元组或我选择的任何值返回给Python中的父元素?