Python time tuples are converted to timestamps, strings

The

python time tuples are converted to timestamps and strings

1, time tuple –> Timestamp

import time
timeArray = time.localtime(time.time())
timeStamp = time.mktime(timeArray)  # 时间戳:1600858387.0

2, time tuple –> String

timeDate = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)  # datetime.datetime:'2020-09-23 18:53:07'
timeDate = time.strftime("%Y-%m-%d", timeArray)  # datetime.date:'2020-09-23'


Read More: