On Thu, 14 Aug 2014 14:52:17 +0800, luofeiyu wrote: > 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 (no characters if no time zone exists). > > > t1='Sat, 09 Aug 2014 07:36:46 ' > time.strptime(t1,"%a, %d %b %Y %H:%M:%S ") > time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, > tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) > > >>> t2='Sat, 09 Aug 2014 07:36:46 -0700' time.strptime(t2,"%a, %d %b > >>> %Y %H:%M:%S %z") > time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, > tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) > > t1 and t2 is different time ,the timezone in t2 is -0700 ,why we get the > same result? > > >>> t3='Sat, 09 Aug 2014 07:36:46 +0400' time.strptime(t3,"%a, %d %b > >>> %Y %H:%M:%S %z") > time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, > tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) > > > The Directive %z has no any effect here,what is the matter?
Please learn to use usenet properly. Comments go below the text they refer to. What version of python are you using? I know what version of the documentation you are looking at, but as I explained inj an earlier post, the implementation varies between different python versions, and for example python 2.7 strptime seems to completely ignore the %z in the format string, so again, what version of python are you using? To check your python version: $ python >>> import sys >>> sys.version will output something like: '2.7.3 (default, Feb 27 2014, 19:58:35) \n[GCC 4.6.3]' for Python 2.7 or: '3.2.3 (default, Feb 27 2014, 21:31:18) \n[GCC 4.6.3]' for Python 3.2. Again, I stress, we need to know what version of python you are using to help you! Did you run the code I posted? Did you get the same output as me? If you didn't, what was different. If you did get the same output, what do you think is wrong with it? -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list