how to change the time string into number?
Roy Smith
roy at panix.com
Wed Aug 13 23:14:58 EDT 2014
In article <53ec2453$0$2299$426a74cc at news.free.fr>,
YBM <ybmess at nooos.fr.invalid> wrote:
> Le 14/08/2014 04:16, Tim Chase a écrit :
> > On 2014-08-13 21:01, Tim Chase wrote:
> >> On 2014-08-14 09:46, luofeiyu wrote:
> >>> s="Aug"
> >>>
> >>> how can i change it into 8 with some python time module?
> >>
> >> >>> import time
> >> >>> s = "Aug"
> >> >>> time.strptime(s, "%b").tm_mon
> >> 8
> >>
> >> works for me.
> >
> > Or, if you want a more convoluted way:
> >
> > >>> import calendar as c
> > >>> [i for i, m in enumerate(c.month_abbr) if m == "Aug"].pop()
> > 8
>
> it's a joke isn't it ?
No, it's a song.
If I could save time in a bottle
The first thing that I'd like to do
Is to make every month be an integer number
And then I could count them with you.
More information about the Python-list
mailing list