擅长:python、mysql、java
<p><code>.localize()</code>接受一个简单的datetime对象,并将其解释为<em>就好像</em>它在那个时区一样。它不会将时间移到另一个时区。一个简单的datetime对象有<em>no</em>时区信息,可以使移动成为可能。</p>
<p>您想在您的本地时区中解释<code>now()</code>,然后使用<code>.astimezone()</code>来解释另一时区中的日期时间:</p>
<pre><code>est = timezone('US/Eastern')
cst = timezone('US/Central')
curtime = cst.localize(datetime.datetime.now())
est_curtime = curtime.astimezone(est).strftime("%a %b %d %H:%M:%S %Z %Y"))
def run(self):
print "%s says Hello World at time: %s" % (self.getName(), est_curtime)
</code></pre>