python time模塊

1.python 中的time 模塊

  time模塊主要是進行時間上處理.我用一個圖來表示time,其中涉及到三種概念:時間戳,時間結構體,

時間字符串

wKiom1hrZaTyjKC3AAAsBL4Y4Gs885.png-wh_50

time 模塊主要是處理這三個的關係.

2.time模塊中的函數介紹.

    2.1 time.localtime() 這個函數用於將時間戳  轉換成time_struct 時間,不傳參,默認是當前的時間戳.

      2.2 time.time() 獲取當前的時間戳,

      2.3 mktime 獲取時間戳,輸入參數是 時間結構體 time_struct


      2.4 strftime(format,struct time) 將時間結構體 轉換成時間字符串.

      2.5 strptime(str, format) 將字符串轉換成 time struct. 

      2.6 asctime() 有時間戳 轉換成時間字符串

      2.7 clock()  獲取CPU佔用時的時間戳.

Python中時間模塊很多,有time,datetime,calender。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章