2016-06-08

python時間函數(time)

22:52 Posted by ZMH 2 comments
電腦時間參考標準:
1970/1/1 00:00:00(又稱為epoch)

time.time()
返回自epoch到現在的時間(秒)
time.timzone
存著時區的offset值(Asia<0;UK=0;US>0)
==========================================
time.gmtime([secs])
將自epoch到現在的時間轉換成結構化的"GMT"時間
沒有傳入參數,即是傳入當前時間

calendar.timegm(tuple)
time.gmtime的相反函數,傳入結構化的GMT時間
返回從epoch到傳入的時間(秒)
==========================================
time.localtime([secs])
將自epoch到現在的時間轉換成結構化的"當地"時間
沒有傳入參數,即是傳入當前時間

time.mktime(t)
time.localtime的相反函數,傳入結構化的當地時間
返回從epoch到傳入的時間(秒)
==========================================
time.strftime(format[, t])
將結構化時間格式化成想要的格式

time.clock()
顯示程序開始執行後的經過時間(秒)

python3.3後:
time.clock()已不被建議
改建議使用:
time.perf_counter()
傳回程序執行的時間(包含程序等待的時間)
因為時間參考原點未定,需要使用兩次的差值!
time.process_time()
傳回程序使用的CPU運算時間(不包含程序等待的時間)
因為時間參考原點未定,需要使用兩次的差值!
==========================================
待補上計時程式..

補充:
UTC時間和GMT時間的差異:
http://pansci.asia/archives/84978

2 則留言:

  1. youtube | vc-novel-r1.jpg | vc-novel-r1.jpg
    youtube. Video. youtube. video. YouTube. video. youtube. YouTube. video. mp3 juice youtube. video. youtube. video. youtube. youtube. video. youtube. youtube. video. youtube. youtube. YouTube. video. youtube. youtube. youtube. youtube. video. youtube. YouTube. video.

    回覆刪除
  2. 1xbet - Best Bet in 1xBet - Download or Install for Android
    1xbet is the best betting app 메이피로출장마사지 in the world created for 1xbet 먹튀 esports. ventureberg.com/ It is a one of the safest and most trusted wooricasinos.info names among players. It offers a user deccasino friendly interface

    回覆刪除