Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76257
| From | Roy Smith <roy@panix.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: how to change the time string into number? |
| Date | 2014-08-13 23:14 -0400 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <roy-EBE10D.23145813082014@news.panix.com> (permalink) |
| References | <53EC14EC.2090503@gmail.com> <20140813210111.197005cd@bigbox.christie.dr> <mailman.12958.1407982655.18130.python-list@python.org> <53ec2453$0$2299$426a74cc@news.free.fr> |
In article <53ec2453$0$2299$426a74cc@news.free.fr>, YBM <ybmess@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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: how to change the time string into number? Tim Chase <python.list@tim.thechases.com> - 2014-08-13 21:16 -0500
Re: how to change the time string into number? YBM <ybmess@nooos.fr.invalid> - 2014-08-14 04:51 +0200
Re: how to change the time string into number? Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-13 21:07 -0600
Re: how to change the time string into number? Roy Smith <roy@panix.com> - 2014-08-13 23:14 -0400
Re: how to change the time string into number? Marko Rauhamaa <marko@pacujo.net> - 2014-08-14 08:19 +0300
csiph-web