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


Groups > comp.lang.python > #76336

Re: how to change the time string into number?

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.python
Subject Re: how to change the time string into number?
Date 2014-08-14 23:37 +0000
Organization A noiseless patient Spider
Message-ID <lsjh6v$osa$5@dont-email.me> (permalink)
References <mailman.12951.1407980799.18130.python-list@python.org>

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

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

csiph-web