关于python时间

import time
# 获得当前时间时间戳
now = int(time.time())  #->这是时间戳
# 转换为其他日期格式, 如: "%Y-%m-%d %H:%M:%S"
timeArray = time.localtime(now)

otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
print(now)
print(timeArray)
print(otherStyleTime)

 

复杂的时间处理,可以用arrow时间库使用详解https://xin053.github.io/2016/07/04/arrow%E6%97%B6%E9%97%B4%E5%BA%93%E4%BD%BF%E7%94%A8%E8%AF%A6%E8%A7%A3/

猜你喜欢

转载自blog.csdn.net/supramolecular/article/details/81868562