python自动化测试——时间戳转日期

import datetime
#十位时间戳
timeStamp = 1568131200
otherStyleTime = datetime.datetime.utcfromtimestamp(timeStamp).strftime("%Y-%m-%d %H:%M:%S")
print(otherStyleTime)  #2019-09-10 16:00:00

import time
#十三位时间戳
timeStamp = 1568131200000
otherStyleTime = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(timeStamp/1000))
print(otherStyleTime) #2019-09-11 00:00:00
posted @ 2019-09-10 16:48  OTAKU_nicole  阅读(289)  评论(0编辑  收藏  举报