[英]Time of the current day in seconds in Python
我知道如何以秒為單位獲取當天的時間
import time
seconds=time.time() % 86400
但是,結果對 UTC 有效。 本地時間有沒有優雅的方法來做到這一點? 我知道我可以從當地時間struct_time
以某種方式得到它,但這將是一個相當復雜的過程。 有什么優雅的方法可以做到這一點嗎?
從struct_time
獲取它並不復雜。
t = time.localtime()
secs = 3600 * t.tm_hour + 60 * t.tm_min + t.tm_sec
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.