python的时间获取与转化:time模块和datetime模块

1.三种时间:UTC time,local time,epoch time
2.三种时间表示:timestamp,struct_time,format time


3.time.time()返回时间戳;time.localtime()返回时间元组;time.strftime('%Y-%m-%d' , time.localtime())返回格式化时间
time.strptime('2018年12月08日 34时10分04秒' , '%Y年%m月%d日 %M时%I分%S秒') 解析字符串返回时间元组

4.datetime模块是对time的进一步封装,主要是5个类:date,time,datetime,timedelta,tzinfo。


5.date.today(),date.fromtimestamp(timestamp),d.weekday(),d.strftime(format)
6.datetime.today(),datetime.now([tz])
7.timedelta内部值存储days,seconds,microseconds.其他所有值都被转为这三个参数。
8.td.days(),td.seconds()

 

 

posted @ 2022-03-21 10:52  小小小小尼  阅读(153)  评论(0)    收藏  举报