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。

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