【发布时间】:2017-08-14 15:04:15
【问题描述】:
我有一个脚本,但它不能正常工作,所以在 bash 中我让脚本进入 while 循环,我希望我的脚本可以在一段时间后自行关闭,我尝试使用 threading.timer 但我的代码无法运行 @987654322 @ 或 exit() 命令,谁能帮帮我?
#!/usr/bin/env python3
import threading
from time import sleep
def qu():
print("bye")
exit()
t=threading.Timer(5.0,qu)
t.start()
while(True):
sleep(1)
print("hi")
【问题讨论】:
标签: python python-multithreading python-3.6