文章詳情頁
python如何手動實現阻塞
瀏覽:205日期:2022-08-10 10:24:43
問題描述
python 如何手動實現阻塞?
令py腳本一直阻塞直到強制退出(KeyboardInterrupt)
之前用
while True: pass
發現cpu占用太高了。。。
問題解答
回答1:1. 使用time.sleepwhile True: # 等待一年 time.sleep(60*60*24*365) # 直接等待一百年time.sleep(60*60*24*365*100)2.使用threading.Condition
condition=threading.Condition()condition.acquire()condition.wait()2.使用等待鍵盤響應
Python實現按任意鍵繼續
回答2:while True: time.sleep(1)
相關文章:
1. javascript - sublime快鍵鍵問題2. javascript - immutable配合react提升性能?3. vue.js - Vue 如何像Angular.js watch 一樣監聽數據變化4. 配置Apache時,添加對PHP的支持時語法錯誤5. css - 寫頁面遇到個布局問題,求大佬們幫解答,在線等,急!~6. javascript - nodejs關于進程間發送句柄的一點疑問7. javascript - 移動端上不能實現拖拽布局嗎?8. phpstudy8.1支持win11系統嗎?9. 實現bing搜索工具urlAPI提交10. Apache 已經把網站根目錄的改為allow from all了,但是服務器還是不能訪問?
排行榜

網公網安備