使用Python2.7,我有timestamsex:timestampMs 1478001612891
我想把它转换成日期格式。在
我试过datetime.fromtimestamp(int('1478013706323'))
但得到这个错误
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ValueError: timestamp out of range for platform localtime()/gmtime() function
datetime.fromtimestamp
需要以秒为单位的输入。把你的数字除以1000.0
,然后再传入。在(根据规范:
datetime.fromtimestamp(timestamp)
将return the local date corresponding to the POSIX timestamp, such as is returned by time.time()
。并且time.time()
将return the time in seconds since the epoch as a floating point number
。)相关问题 更多 >
编程相关推荐