以下示例是关于Python中包含unix转数据时间的python用法的示例代码,想了解unix转数据时间的python的具体用法?unix转数据时间的python怎么用?unix转数据时间的python使用的例子?那么可以参考以下相关源代码片段来学习它的具体使用方法。
>>> from datetime import datetime
>>> ts = int("1284101485")
# if you encounter a "year is out of range" error the timestamp
# may be in milliseconds, try `ts /= 1000` in that case
>>> print(datetime.utcfromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S'))
#'%Y' will be replaced by the year '%m' by the month '%d; by the day and so on
#You move these how you want in the string, other characters will be ignored!
... '2010-09-10 06:51:25'
本文地址:https://www.itbaoku.cn/snippets/785531.html