时间戳与字符串的相互转换

2020-07-13  本文已影响0人  running_sheep

#时间戳转字符串

import time

format_str = "%Y-%m-%d %H:%M:%S"

timestamp = time.time()

timestr = time.strftime(format_str, time.localtime(timestamp))

#字符串转时间戳

time_array = time.strptime(timestr,format_str)

time_stamp = time.mktime(time_array)

上一篇下一篇

猜你喜欢

热点阅读