擅长:python、mysql、java
<blockquote>
<p>New in version 2.6.</p>
<p>For a naive object, the %z and %Z
format codes are replaced by empty
strings.</p>
</blockquote>
<p>看起来这只是在>;=2.6中实现的,我认为您必须手动解析它。</p>
<p>除了删除时区数据,我看不到其他解决方案:</p>
<pre><code>from datetime import timedelta,datetime
try:
offset = int("Tue, 22 Jul 2008 08:17:41 +0300"[-5:])
except:
print "Error"
delta = timedelta(hours = offset / 100)
fmt = "%a, %d %b %Y %H:%M:%S"
time = datetime.strptime("Tue, 22 Jul 2008 08:17:41 +0200"[:-6], fmt)
time -= delta
</code></pre>