Python时间戳与格式化日期相互转换

>>> import time

>>> time.time()

1551074262.4575639

>>> st = time.strptime('2019-02-25 13:08:20', '%Y-%m-%d %H:%M:%S')

>>> time.mktime(st)

1551071300.0

>>> time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())

'2019-02-25 13:59:45'

推荐阅读更多精彩内容