The processing of time in Python is very common
Time.strptime
1. The time.strptime () function resolves a time string to a time tuple according to the specified format. As shown in the following program
2. Grammar
Time.strptime (string[, format])
3. Parameters
- String--time string.
- Format--a formatted string.
4. Return value: Returns the Struct_time object.
5, Python in time date formatting symbols:
- %y Two-digit year representation (00-99)
- %Y Four-digit year representation (000-9999)
- %m Month (01-12)
- One day in%d months (0-31)
- %H 24-hour hours (0-23)
- %I 12-hour hours (01-12)
- %M minutes (00=59)
- %s seconds (00-59)
- %a Local Simplified Week name
- %A Local Full week name
- %b a locally simplified month name
- %B Local Full month name
- %c Local corresponding date representation and time representation
- %j Day of the Year (001-366)
- %p the equivalent of a local a.m. or p.m.
- %u weeks of the year (00-53) Sunday is the beginning of the week
- %w Week (0-6), Sunday for the beginning of the week
- %W Week of the Year (00-53) Monday is the beginning of the week
- %x Local corresponding date representation
- %x Local corresponding time representation
- %Z the name of the current time zone
- Percent% of the number itself
Time Mktime ()
The Python time Mktime () function performs the opposite of Gmtime (), localtime (), which receives the Struct_time object as a parameter and returns a floating-point number that represents the times in seconds.
Official explanation:
Convert a time tuple in local time to seconds since the Epoch.
Is the number of seconds since the beginning of the new era, that is, Unix time (starting January 1, 1970).
Time processing in Python