Python time is a commonly used language for computer applications. If you have any questions about Python time, you can read the following articles to better understand it, the following is a detailed description of the article. I hope you will gain some benefits.
. We pilot a required module
- >>>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() )
- ‘2007-06-02 12:54:29′
We have defined the time format and used strftime to convert the time. If the current Python time is used, time. localtime () does not need to be used.
- >>> time.strftime( ISOTIMEFORMAT, time.localtime( time.time() ) )
- ‘2007-06-02 12:54:31′
- >>> time.strftime( ISOTIMEFORMAT, time.gmtime( time.time() ) )
- ‘2007-06-02 04:55:02′
The difference between gmtime and localtime is shown above. View the time zone
- >>> time.timezone
- -28800
The above article introduces the actual operation steps of Python time.