time 模块

1、时间操作的方法

time.time():获取当前时间戳。

time.ctime():当前时间的字符串形式。

time.localtime():当前时间的 struct_time 形式。

time.strftime():用来获取当前时间,可以将时间格式化为字符串。

import time

t1 = time.time()
print(t1)

t2 = time.ctime()
print(t2)

t3 = time.localtime()
print(t3)

t4 = time.strftime("%Y_%m_%d %H:%M:%S")
print(t4)

输出结果:

 

 

posted @ 2022-07-03 15:44  MToy  阅读(24)  评论(0)    收藏  举报