Python:等待inpu时输出

2024-04-23 15:45:46 发布

您现在位置:Python中文网/ 问答频道 /正文

同时,我仍然需要一个线程来处理输入,而我现在仍然需要一个输出方式。在

现在我有这样的东西

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?


Tags: truetargetrawinformationdef方式线程thread