After searching for half a day, I finally found it on the English site and thanked the rock and fans in the group.
>>> S = datetime. datetime (2009,1, 1)
>>> Time. mktime (S. timetuple ())
1230739200.0
Don't pay for a python time-based function, which is very easy to use.
We pilot a required Module
>>> Import time
Set a time format, which will be used below
>>> Isotimeformat = '% Y-% m-% d % x'
Let's take a look at the current time. Similar to many other languages, this is from epoch (January 1, 1970 00:00:00) to the current number of seconds.
>>> Time. Time ()
1180759620.859
The above cannot be understood. Please change the format to see it.
>>> Time. localtime ()
(2007, 6, 2, 12, 47, 7, 5,153, 0)
Localtime returns the time in tuple format. There is a function similar to it called gmtime (). The difference between the two functions is the time zone, and gmtime () returns the value of the 0 time zone, localtime returns the value of the current time zone.
>>> Time. strftime (isotimeformat, time. localtime ())
'2017-06-02 12:54:29 ′
We have defined the time format and used strftime to convert the time. If the current time is used, time. localtime () does not need to be used.
time. strftime (isotimeformat, time. localtime (time. time ()
'2017-06-02 12:54:31 '
time. strftime (isotimeformat, time. gmtime (time. time ()
'2017-06-02 04:55:02 '
the difference between gmtime and localtime is shown above.
view the time zone
time. timezone
-28800
the value above is a second value, which is the description of the difference between the current time zone and the 0 time zone.-28800 =-8*3600, that is, the UTC + 8 zone.