python获取时间戳

import time

print(time.time())#获当前时间的时间戳
print(time.localtime())#获取本地时间
print(time.strftime('%Y-%m-%d',time.localtime()))#时间格式化

运行结果


1640869331.2432263

time.struct_time(tm_year=2021, tm_mon=12, tm_mday=30, tm_hour=21, tm_min=2, tm_sec=11, tm_wday=3, tm_yday=364, tm_isdst=0)

2021-12-30

Copyright©歪脖博客

备案号:豫ICP备16002920号-3