def findStats():
thread1 = thread.start_new_thread(func1, (arg_1, arg_2))
thread2 = thread.start_new_thread(func2, (arg_3, arg_4))
def func1(arg_1, arg_2):
"""
Some code which prints some stuff
"""
def func2(arg_3, arg_4):
"""
Some code which prints some other stuff
"""
在这里,我想要做的就是捕捉FUNC1和FUNC2打印输出在两个不同的字符串,以便我可以使用,以显示他们在两个不同的标签我的GUI。重定向线程的输出到一个字符串在Python
另外,我尝试使用StringIO(),但由于它们是并行运行的线程,所以输出顺序显然搞砸了。我正在学习使用子过程的东西,但不知道如何......仍在尝试。
可以这样做吗?如果是这样,请给我一个方法。在此先感谢:)
使用它变得复杂。不过,这个想法很好。为了我的需要,我的答案中的代码很好。 – VoodooChild92 2012-07-12 12:21:04