如何退出输入语句python

时间:2016-05-26 01:07:25

标签: python

我需要一种方法在一段时间后继续通过输入语句。正如我所看到的,当有一个包含其他线程的输入语句时,代码会完全停止流动,我已经尝试过了:

import _thread
import time

def print_time(threadName, delay):
   count = 0
   while True:
      time.sleep(delay)
      count += 1
      if count >= 10:
         _thread.interrupt_main()

_thread.start_new_thread(print_time,("Thread-1", 0.5))

while 1:
   try:
      input(">")
   except:
      print("bye")
      input(">")

如果有人想知道如何停止输入声明,我就是开放的,即使它只是一个猜测而且它可能不起作用。

0 个答案:

没有答案