python时间戳与日期相互转换
import time # 时间戳转日期 timeStamp = 1656399821 # 十位时间戳 timeArray = time.localtime(timeStamp) printDate = time.strftime("%Y-%m-%d %H:%M:%S", timeArray) print(printDate) # 2022-06-28 15:03:41 # 日期转时间戳 date = "2022-06-28 10:20:59" timeArray = time.strptime(date, "%Y-%m-%d %H:%M:%S") timeStamp = int(time.mktime(timeArray)) print(timeStamp) # 1656382859
本文来自博客园,作者:OTAKU_nicole,转载请注明原文链接:https://www.cnblogs.com/nicole-zhang/p/16419529.html