good ways to convert string into time

Gerrit Holl gerrit at nl.linux.org
Tue Nov 18 13:15:23 EST 2003


<quote name="Hank" date="1069145888" email="soundwave56 at yahoo.ca">
> i have a string as follows
> 
> 18Nov2003:18:23:43:405

> Is there an easy way to convert that to absolute time? What i really
> want to do is to parse these times from a log file and do time
> comparisons, averages, stop minus start (elapsed).
> 
> Probably create my own conversion table i guess?
</quote>

You can use time.strptime:
strptime(string, format) -> struct_time

Parse a string to a time tuple according to a format specification.
See the library reference manual for formatting codes (same as strftime()).

Gerrit.

-- 
Mozilla _is_ the web: it grows faster than you can download it.
1011001 1101111 1110101 1110010 1110011 0101100
1000111 1100101 1110010 1110010 1101001 1110100





More information about the Python-list mailing list