time 模块 2020年8月16

元组(struct_time)共有9个元素

索引    0     年

              1         月

              2         日

              3         时

              4         分

              5         秒

              6         周(0~6,0表示周一)

              7         天  (一年中的第几天)

 

time.strftime(“%Y-%m-%d %H:%M:%S”)   #格式化时间

year  month  day   hour minute  second

%y  两位数的年份表示

%Y  四位数的年份表示

%a  本地简化星期名称

%A  本地完整星期名称

%b   本地简化月份名称

%B      本地完整月份名称

%j     年内的一天(001~366)

time.localtime()  返回一个元组。结构化时间。

 

 

time.time()  得到的是timestamp 格式的时间。

 

原文地址:https://www.cnblogs.com/liu1983/p/13513035.html