我想每5秒將字母X追加到列表中。我的代碼到目前爲止:每隔5秒追加
import threading
def Seconds():
threading.Timer(5.0, Seconds).start()
List = []
n = "X"
List.append(n)
print List
Seconds()
我想擁有一個列表,每5秒增長一次,並保存到一個TXT。每5秒記錄一次。此代碼的目的是檢查我的電池供電系統的運行時間。代碼與系統一起啓動。當電池電量不足時,我想讀出文本文件以查看代碼的執行時間,因此我的系統能夠使用電池運行多久。
爲什麼不使用隊列?他們是線程安全的。 –