1. Time Module
ImportTime,datetime#print (Time.time ()) #时间戳#Print (Time.strftime ("%y-%m-%d%x")) #格式化时间#print (Time.localtime ()) #本地的struct_time#print (Time.gmtime ()) #本地的utc时间#print (Time.ctime ()) #英文日期#time plus minusPrint(Datetime.datetime.now ())#Displays the current time in millisecondsPrint(Datetime.date.fromtimestamp (Time.time ()))#turn timestamps directly into date formatsPrint(Datetime.datetime.now () + Datetime.timedelta (3))#Show now time plus three daysPrint(Datetime.datetime.now () + Datetime.timedelta (-3))#show current time minus three daysPrint(Datetime.date.fromtimestamp (Time.time ()) + Datetime.timedelta (3))#Current time rounding plus threePrint(Datetime.date.fromtimestamp (Time.time ()) + Datetime.timedelta (-3))#Current time rounding minus threePrint(Datetime.datetime.now () + Datetime.timedelta (hours=3))#Show now time plus three hoursPrint(Datetime.datetime.now ()-Datetime.timedelta (hours=3))#show current time minus three hoursPrint(Datetime.datetime.now () + Datetime.timedelta (minutes=30))#Show now time plus 30 points#Time SubstitutionNow_time =Datetime.datetime.now ()Print(Now_time.replace (minute=3,hour=2))
- Where the computer knows time can only be ' timestamp ' format, and the programmer can deal with or say that human can understand the time is: ' Formatted time string ', ' structured time ', so there is a conversion relationship
Python Common Module series