import time
time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
Out[7]: '2021-03-31 02:48:51'
time.strftime("%a %b %d %H:%M:%S %Y", time.localtime())
Out[9]: 'Wed Mar 31 02:50:41 2021'
# 将格式字符串转换为时间戳
a = 'Wed Mar 31 02:50:41 2021'
time.mktime(time.strptime(a,"%a %b %d %H:%M:%S %Y"))
Out[12]: 1617159041.0
python 格式化日期time
最新推荐文章于 2024-07-30 15:58:59 发布