python time函数应用

#休眠函数
def wait():
    time.sleep(4)

start=time.perf_counter()
wait()
end=time.perf_counter()
print(end-start)

输出:
4.0041136
#时间格式化输出
t=time.gmtime()
tt=time.strftime("%Y-%m-%d %H:%M:%S",t)
print(tt)

输出:
2021-10-26 13:25:58

猜你喜欢

转载自blog.csdn.net/weixin_47401101/article/details/120981548