Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'indices': 0.07; 'locale': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:into': 0.09; 'subject:number': 0.09; 'subject:string': 0.09; 'python': 0.11; '(none,': 0.16; 'module?': 0.16; 'non-english': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'header:User-Agent:1': 0.23; 'skip:" 30': 0.26; 'header:X -Complaints-To:1': 0.27; 'writes:': 0.31; 'subject:time': 0.33; 'subject:the': 0.34; 'subject:?': 0.36; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'note:': 0.66; 'received:89': 0.85 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Akira Li <4kir4.1i@gmail.com> Subject: Re: how to change the time string into number? Date: Wed, 20 Aug 2014 18:01:24 +0400 References: <53EC14EC.2090503@gmail.com> Mime-Version: 1.0 Content-Type: text/plain X-Gmane-NNTP-Posting-Host: 89.169.229.68 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:clNNmuS2F82D5OmtP9eFdafotUE= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408543323 news.xs4all.nl 2943 [2001:888:2000:d::a6]:54810 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76664 luofeiyu writes: > s="Aug" > > how can i change it into 8 with some python time module? months = (None, # dummy, to start month indices from 1 "Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec" ) month_number = months.index(month_abbr) # month_abbr == "Aug" Note: - time.strptime(month_abbr, "%b").tm_mon may fail in non-English locale - list(calendar.month_abbr).index(month_abbr) is also locale-specific -- Akira