(模块名)time.time()(方法名)
time.strftime('%Y_%m_%d %X') # 2019_08_16 10:26:36
time.localtime() # 当地时间(中国)
time.gmtime() # 标准时间
# time.struct_time(tm_year=2019, tm_mon=8, tm_mday=16, tm_hour=19, tm_min=42, tm_sec=44, tm_wday=4, tm_yday=228, tm_isdst=0)
# time.struct_time(tm_year=2019, tm_mon=8, tm_mday=16, tm_hour=11, tm_min=42, tm_sec=44, tm_wday=4, tm_yday=228, tm_isdst=0)
print(time.strftime('%Y-%m-%d %X', time.localtime()))
# 2019-08-16 19:42:44
print(time.strptime('2019-08-16 10:30:44', '%Y-%m-%d %X'))
# time.struct_time(tm_year=2019, tm_mon=8, tm_mday=16, tm_hour=10, tm_min=30, tm_sec=44, tm_wday=4, tm_yday=228, tm_isdst=-1)
print(time.mktime(time.localtime()))
# 1565955764.0
print(time.localtime(time.time()))
# time.struct_time(tm_year=2019, tm_mon=8, tm_mday=16, tm_hour=19, tm_min=42, tm_sec=44, tm_wday=4, tm_yday=228, tm_isdst=0)
time.time()
time.sleep()
原文:https://www.cnblogs.com/xichenHome/p/11366339.html