python日期,时间函数

获取当前格式化时间:

now_time = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())

获取当前时间戳:

now_timestamp = int(time.time())
格式更改:先转换为时间数组
a = "2013-10-10 23:40:00",
timeArray = time.strptime(a, "%Y-%m-%d %H:%M:%S")
timestamp = int(time.mktime(timeArray))
otherStyleTime = time.strftime("%Y/%m/%d %H:%M:%S", timeArray)
otherStyleTime = "2013/10/10 23:40:00"
原文地址:https://www.cnblogs.com/BigFishFly/p/6337193.html