1. import time
    2. import datetime
    3. timestamp = 1570774556514
    4. # 转换成localtime
    5. time_local = time.localtime(timestamp/1000)
    6. # 转换成新的时间格式(精确到秒)
    7. dt = time.strftime("%Y-%m-%d %H:%M:%S", time_local)
    8. print(dt) # 2019-10-11 14:15:56
    9. d = datetime.datetime.fromtimestamp(timestamp/1000)
    10. # 精确到毫秒
    11. str1 = d.strftime("%Y-%m-%d %H:%M:%S.%f")
    12. print(str1) # 2019-10-11 14:15:56.514000