Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76241 > unrolled thread

how to change the time string into number?

Started byluofeiyu <elearn2014@gmail.com>
First post2014-08-14 09:46 +0800
Last post2014-08-14 23:37 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  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

#76241 — how to change the time string into number?

Fromluofeiyu <elearn2014@gmail.com>
Date2014-08-14 09:46 +0800
Subjecthow 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]


#76336

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-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