1. Time stamp
1 Import Time 2 # ------->> Timestamps 3 Print (Time.time ())
1 1525418832.2835853
2. Structured time
1 # ------->> structured time 2print(Time.localtime ())3print (Time.gmtime ()) 4 Print (Time.localtime (). Tm_mday)
1 time.struct_time (tm_year=2018, tm_mon=5, tm_mday=4, tm_hour=15, tm_min=28, tm_sec=32, tm_wday=4, tm_yday= 124, tm_isdst=0)2 time.struct_time (tm_year=2018, tm_mon=5, tm_mday=4, tm_hour=7, tm_min=28, tm_ Sec=32, tm_wday=4, tm_yday=124, tm_isdst=0)3 4
3. The structured time is turned into time stamp
1 # ------->> turn a structured time into a timestamp 2 Print (Time.mktime (Time.localtime ()))
1 1525418978.0
4. Structured time turns into string time
1 # ------->> turn structured time into string time 2print(Time.strftime ("%y-%m-%d%x ", Time.localtime ())) # The seconds after the second can be simplified with%x to write 3print( Time.strftime ("%y-%m-%d%h:%m:%s", Time.localtime ()))
1 2018-05-04 15:30:522 2018-05-04 15:30:52
5. The string time is converted into structured time
1 # ------->> Turn string time into structured time 2 Print (Time.strptime ("2018-5-4 16:10:9","%y-%m-%d%x"))
Time.struct_time (tm_year=2018, tm_mon=5, tm_mday=4, tm_hour=16, tm_min=10, tm_sec=9, tm_wday=4, tm_yday=124, tm_isdst= -1)
6. The default simplified string time (in the form of Westernization)
1 Print (Time.asctime ()) 2 Print (Time.ctime ())
1 Fri 4 15:32:39 20182 Fri May 4 15:32:39 2018
7, also similar to the time of the string
1 Import datetime 2 Print (Datetime.datetime.now ())
1 2018-05-04 15:33:57.990908
Python Module--time module