import time print(time.time())#获当前时间的时间戳 print(time.localtime())#获取本地时间 print(time.strftime('%Y-%m-%d',time.localtime()))#时间格式化 -----------运行结果--------------------------- 1565681079.7931128 time.struct_time(tm_year=2019, tm_mon=8, tm_mday=13, tm_hour=15, tm_min=24, tm_sec=39, tm_wday=1, tm_yday=225, tm_isdst=0) 2019-08-13