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


Groups > comp.lang.python > #76249

Re: how to change the time string into number?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:into': 0.09; 'subject:number': 0.09; 'subject:string': 0.09; 'way:': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'module?': 0.16; 'to:name:tim chase': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'cc:addr:gmail.com': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'chase': 0.31; 'subject:time': 0.33; 'subject:the': 0.34; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'how': 0.40; 'more': 0.64; 'received:50.22': 0.84
Date Wed, 13 Aug 2014 21:16:05 -0500
From Tim Chase <python.list@tim.thechases.com>
To Tim Chase <tim@thechases.com>
Subject Re: how to change the time string into number?
In-Reply-To <20140813210111.197005cd@bigbox.christie.dr>
References <53EC14EC.2090503@gmail.com> <20140813210111.197005cd@bigbox.christie.dr>
X-Mailer Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
X-Get-Message-Sender-Via boston.accountservergroup.com: authenticated_id: tim@thechases.com
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12958.1407982655.18130.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1407982655 news.xs4all.nl 2909 [2001:888:2000:d::a6]:52592
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76249

Show key headers only | View raw


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

-tkc


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


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