Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76241 > unrolled thread
| Started by | luofeiyu <elearn2014@gmail.com> |
|---|---|
| First post | 2014-08-14 09:46 +0800 |
| Last post | 2014-08-14 23:37 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
how to change the time string into number? luofeiyu <elearn2014@gmail.com> - 2014-08-14 09:46 +0800
Re: how to change the time string into number? Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-14 23:37 +0000
| From | luofeiyu <elearn2014@gmail.com> |
|---|---|
| Date | 2014-08-14 09:46 +0800 |
| Subject | how to change the time string into number? |
| Message-ID | <mailman.12951.1407980799.18130.python-list@python.org> |
s="Aug" how can i change it into 8 with some python time module?
[toc] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2014-08-14 23:37 +0000 |
| Message-ID | <lsjh6v$osa$5@dont-email.me> |
| In reply to | #76241 |
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@gmail.com
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web