python 时间戳转为字符串

方法一

import datetime
import time

stamp = int(time.time())
print datetime.datetime.fromtimestamp(stamp)
2017-07-29 16:08:32

方法二

>>> time.strftime("%Y-%m-%d %H:%M", time.localtime(stamp))
'2017-07-29 16:08'
>>>

你可能感兴趣的:(python,python)