import time
year = 2020
month = 1
day = 20
dateStr = "{}-{}-{}".format(year, month, day)
print(dateStr)
# 时间字符串解析为时间元组
timeArray = time.strptime(dateStr, "%Y-%m-%d")
# 将时间元组转换为时间戳:
timeStamp = int(time.mktime(timeArray))
print(timeStamp)
# 格式化时间戳为时间元组
timeArray = time.localtime(timeStamp)
# 将时间元组转换为时间字符串
timeStr = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
print(timeStr)