[英]how to make timer for quiting from python3
我有一個腳本,它無法正常工作,所以在bash中,我讓腳本進入while循環,我想我的腳本可以在一段時間后自行關閉,我嘗試使用threading.timer
但是我的代碼無法運行quit()
或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")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.