2019-12-06--时间戳与时间之间转换

import time

#将时间戳转换为时间

time_stamp = 1575594679

a = time.localtime(time_stamp) 

time1 = time.strftime("%Y-%m-%d %H:%M:%S",a)

print(time1)

#将时间转换为时间数组

a = "2019-12-06 09:11:19"

b = time.strptime(a,'%Y-%m-%d %H:%M:%S')

print(b)

#print(b.tm_year)

#print(b.tm_mon)

#将时间转换为时间戳

a = "2019-12-06 09:11:19"

b = time.strptime(a,'%Y-%m-%d %H:%M:%S')

c = time.mktime(b)

print(c)

你可能感兴趣的:(2019-12-06--时间戳与时间之间转换)