Python:等待输入时输出

时间:2017-03-30 18:46:28

标签: python multithreading python-2.x

所以我目前有一个正在输出的线程,我需要一种处理输入的方法,同时仍允许线程输出。

目前我有类似的东西

def thread_func():
    while True:
        print("Information")

threading.Thread(target=thread_func).start()

while True:
    command = raw_input("Enter a command:")
    #dostuff with command

我现在的问题是我的帖子没有打印任何东西。或者如果它没有出现

修改

在这里找到解决方案 Exiting while loop by pressing enter without blocking. How can I improve this method?

1 个答案:

答案 0 :(得分:-1)

您想使用Queue。新输入将进入队列的后面,并且将从前面开始工作。