how to change the time string into number?
Ben Finney
ben+python at benfinney.id.au
Wed Aug 13 22:01:59 EDT 2014
luofeiyu <elearn2014 at gmail.com> writes:
> s="Aug"
>
> how can i change it into 8 with some python time module?
What is your purpose here? If you want to parse a text value into a
structured time object, don't do it piece by piece. Use the
‘time.strptime’ function.
>>> import time
>>> input_time_text = "14 Aug 2014"
>>> input_time = time.strptime(input_text, "%d %b %Y")
>>> input_time.tm_mon
8
--
\ “I knew it was a shocking thing to say, but … no-one has the |
`\ right to spend their life without being offended.” —Philip |
_o__) Pullman, 2010-03-28 |
Ben Finney
More information about the Python-list
mailing list