Re: how to change the time string into number?

2014-08-20 Thread Akira Li
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

Re: how to change the time string into number?

2014-08-15 Thread Denis McMahon
On Thu, 14 Aug 2014 14:52:17 +0800, luofeiyu wrote: > in the manual https://docs.python.org/3.4/library/time.html > > %zTime zone offset indicating a positive or negative time difference > from UTC/GMT of the form +HHMM or -HHMM, where H represents decimal hour > digits and M represents deci

Re: how to change the time string into number?

2014-08-14 Thread Denis McMahon
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

Re: how to change the time string into number?

2014-08-14 Thread Ben Finney
Dennis Lee Bieber writes: > "Android" /is/ the flavor > > Though Google has probably done some things to it that make it > "not-Linux". Android is definitely Linux, since that is the kernel Android runs. Remember that Linux is not an operating system; it is one part, the kernel. Th

Re: how to change the time string into number?

2014-08-14 Thread Roy Smith
In article , Dennis Lee Bieber wrote: > On Thu, 14 Aug 2014 17:47:00 +1000, Cameron Simpson > declaimed the following: > > > > >Your Android phone will be running some flavour of Linux I believe. Someone > >who > >has used one may correct me here. > > > "Android" /is/ the flavor > >

Re: how to change the time string into number?

2014-08-14 Thread Mark Lawrence
On 14/08/2014 02:46, luofeiyu wrote: s="Aug" how can i change it into 8 with some python time module? If all else fails, read the instructions, so start here https://docs.python.org/3/library/datetime.html#module-datetime -- My fellow Pythonistas, ask not what our language can do for you, a

Re: how to change the time string into number?

2014-08-14 Thread Cameron Simpson
On 14Aug2014 14:52, luofeiyu wrote: in the manual  https://docs.python.org/3.4/library/time.html ┌──┬──┬─┐ │ │Time zone offset indicating a positive or negative time difference│ │ │%z│from UTC/GMT of the form +HHMM or -HHM

Re: how to change the time string into number?

2014-08-14 Thread Cameron Simpson
On 14Aug2014 15:30, luofeiyu wrote: import sys sys.version '3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)]' First, please post in an interleaved style so that we can see your responses underneath the text to which they relate. Thanks. Ok, you have Python 3.4

Re: how to change the time string into number?

2014-08-14 Thread luofeiyu
>>> import sys >>> sys.version '3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)]' >>> import time >>> time.tzname ('China Standard Time', 'China Daylight Time') On 8/14/2014 3:25 PM, Cameron Simpson wrote: On 14Aug2014 14:52, luofeiyu wrote: in the manual http

Re: how to change the time string into number?

2014-08-14 Thread Ben Finney
Please don't top-post your response. Instead, interleave your response and remove irrelevant quoted material. Use the Interleaved style https://en.wikipedia.org/wiki/Posting_style#Interleaved_style>. luofeiyu writes: > in the manual https://docs.python.org/3.4/library/time.html > > %zTime z

Re: how to change the time string into number?

2014-08-13 Thread luofeiyu
in the manual https://docs.python.org/3.4/library/time.html %z Time zone offset indicating a positive or negative time difference from UTC/GMT of the form +HHMM or -HHMM, where H represents decimal hour digits and M represents decimal minute digits [-23:59, +23:59]. %Z Time zone name

Re: how to change the time string into number?

2014-08-13 Thread Marko Rauhamaa
Tim Chase : > 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 Let's not forget the much simpler solutions: >>> def eight(x): return 8 ... >>> eight("Aug") 8 and: >>> 8 8 BTW,

Re: how to change the time string into number?

2014-08-13 Thread Roy Smith
In article <53ec2453$0$2299$426a7...@news.free.fr>, YBM wrote: > Le 14/08/2014 04:16, Tim Chase a écrit : > > 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

Re: how to change the time string into number?

2014-08-13 Thread Ian Kelly
On Wed, Aug 13, 2014 at 8:51 PM, YBM wrote: > BTW, why iterators does not have such an index method ? Because iterators don't support indexing. In order to support such a thing, it would have to exhaust the iterator. >>> iter(range(5))[3] Traceback (most recent call last): File "", line 1, in

Re: how to change the time string into number?

2014-08-13 Thread YBM
Le 14/08/2014 04:16, Tim Chase a écrit : 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 mo

Re: how to change the time string into number?

2014-08-13 Thread Tim Chase
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: >>

Re: how to change the time string into number?

2014-08-13 Thread Tim Chase
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. -tkc -- https://mail.python.org/mailman/listinfo/python-list

Re: how to change the time string into number?

2014-08-13 Thread Ben Finney
luofeiyu writes: > s="Aug" > > how can i change it into 8 with some python time module? What is your purpose here? If you want to parse a text value into a structured time object, don't do it piece by piece. Use the ‘time.strptime’ function. >>> import time >>> input_time_text = "14 Aug

Re: how to change the time string into number?

2014-08-13 Thread Chris Angelico
On Thu, Aug 14, 2014 at 11:46 AM, luofeiyu wrote: > s="Aug" > > how can i change it into 8 with some python time module? Is this homework? If not, let me set you some homework. Step 1: Read the docs for some Python time module. Step 2: See if it lets you do what you want. Step 3: Return to step

how to change the time string into number?

2014-08-13 Thread luofeiyu
s="Aug" how can i change it into 8 with some python time module? -- https://mail.python.org/mailman/listinfo/python-list