Python IIS日志时隙时区

Python IIS日志时隙时区,python,datetime,iis,Python,Datetime,Iis,我有一些需要处理的IIS(Internet信息服务)日志,如果你是Linux服务器的话,比如Apache web日志 web日志以以下内容开头: 49.76.xx.xx - - [01/Jun/2015:00:01:08 -0500] "GET... 我很好奇时间戳,[01/Jun/2015:00:01:08-0500],在这个场景中,0500是什么意思?它是否类似于基于python文档的时区或偏移量 这是我迄今为止所做的,但不起作用: from datetime import datetim

我有一些需要处理的IIS(Internet信息服务)日志,如果你是Linux服务器的话,比如Apache web日志

web日志以以下内容开头:

49.76.xx.xx - - [01/Jun/2015:00:01:08 -0500] "GET...
我很好奇时间戳,
[01/Jun/2015:00:01:08-0500]
,在这个场景中,0500是什么意思?它是否类似于基于python文档的时区或偏移量

这是我迄今为止所做的,但不起作用:

from datetime import datetime
text = "01/Jun/2015:00:01:08 +0500"
print datetime.strptime(text, '%d/%b/%Y:%H:%M:%S %z')
下面是错误消息

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-10-e243ceb157eb> in <module>()
      1 from datetime import datetime
      2 text = "01/Jun/2015:00:01:08 +0500"
----> 3 print datetime.strptime(text, '%d/%b/%Y:%H:%M:%S %z')

/opt/local/anaconda/lib/python2.7/_strptime.pyc in _strptime(data_string, format)
    315                 del err
    316                 raise ValueError("'%s' is a bad directive in format '%s'" %
--> 317                                     (bad_directive, format))
    318             # IndexError only occurs when the format string is "%"
    319             except IndexError:

ValueError: 'z' is a bad directive in format '%d/%b/%Y:%H:%M:%S %z'
---------------------------------------------------------------------------
ValueError回溯(最近一次调用上次)
在()
1从datetime导入datetime
2 text=“01/Jun/2015:00:01:08+0500”
---->3打印日期时间.strTime(文本,“%d/%b/%Y:%H:%M:%S%z”)
/opt/local/anaconda/lib/python2.7//u strptime.pyc in.\u strptime(数据字符串,格式)
315德勒
316 raise VALUERROR(“%s”是格式为“%s”的错误指令%
-->317(bad_指令,格式))
318#索引器仅在格式字符串为“%”时发生
319除索引器外:
ValueError:“z”是错误的指令,格式为“%d/%b/%Y:%H:%M:%S%z”

%z
表示时区。。您不能将
%z
.strtime()
一起使用。。你可以考虑使用<代码> Pytz < /Cult>模块为时区

<代码> -0500 是时区偏移,这意味着这个特定的本地时间在UTC后面是5小时。不要将偏移量与时区混淆,因为许多时区会因夏令时和其他异常情况而更改其偏移量。另外,要小心-在一种情况下显示
-0500
,在另一种情况下显示
+0500
。它们彼此相隔10小时。