how to change the time string into number?

Denis McMahon denismfmcmahon at gmail.com
Thu Aug 14 19:37:03 EDT 2014


On Thu, 14 Aug 2014 09:46:20 +0800, luofeiyu wrote:

> s="Aug"
> 
> how can i change it into 8 with some python time module?

You don't need a time module for this, just use a dictionary:

months = { "Jan" : 1, ..... , "Dec": 12 }
num = months[s]
print num

Fill in the rest of the months dictionary yourself, it shouldn't be too 
hard.

-- 
Denis McMahon, denismfmcmahon at gmail.com



More information about the Python-list mailing list