我希望我的Python2守護進程能夠在第二個時刻醒來並完成某些操作。獲取python中的浮點數的小數部分
有沒有更好的方式來獲得一個浮點數的DECMAL一部分以外的睡眠時間,那麼:這取決於有多少工作在本次做
now = time.time() #get the current time in a floating point format
left_part = long(now) #isolate out the integer part
right_part = now - left_part #now get the decimal part
time.sleep(1 - right_part) #and sleep for the remaining portion of this second.
的睡眠時間是可變的。
是否有「睡眠直到」功能我不知道?或者, 有沒有更好的方法來處理這個問題?
我希望我的守護進程儘可能高效,以免從其他進程中佔用過多的CPU。
謝謝。標記。
你試過用谷歌搜索你的問題的標題(拼寫錯誤已更正)嗎? – TigerhawkT3
[相關問題](https://stackoverflow.com/questions/3886402/python-how-to-get-numbers-after-decimal-point) – ChaimG