time模块应用

import time

# 时间戳
the_time = 1629891682.7282898
print(the_time)

# 时间戳转结构再转格式
struct_time = (time.localtime(the_time))
print(struct_time)
str_time = (time.strftime("%Y-%m-%d %H:%M:%S", struct_time))

# 格式化时间转时间戳
struct_time1 = (time.strptime(str_time, "%Y-%m-%d %H:%M:%S"))
print(struct_time1)
last_time = time.mktime(struct_time)
print(last_time)

  

import time

# 时间戳
the_time = 1629891682.7282898
print(the_time)

# 时间戳转结构再转格式
struct_time = (time.localtime(the_time))
print(struct_time)
str_time = (time.strftime("%Y-%m-%d %H:%M:%S", struct_time))

# 格式化时间转时间戳
struct_time1 = (time.strptime(str_time, "%Y-%m-%d %H:%M:%S"))
print(struct_time1)
last_time = time.mktime(struct_time)
print(last_time)

  

posted on 2021-08-26 08:15  zl666张良  阅读(31)  评论(0)    收藏  举报