获得本机时间
import time print(time.strftime('%Y-%m-%d %A %X %Z',time.localtime(time.time()))) # 2020-09-28 Monday 11:35:07 中国标准时间 a = time.localtime(time.time()) # 获得时间对像time.struct_time(tm_year=2020, tm_mon=9, tm_mday=28, tm_hour=11, tm_min=35, tm_sec=7, tm_wday=0, tm_yday=272, tm_isdst=0) year =a.tm_year mon = a.tm_mon print(year,mon)