如何让 Python 显示东部时间?
我查看了 python 文档,但它非常令人困惑。我正在使用 Python 3。
最佳答案
当然还有更直观的方法:
from datetime import datetime
from pytz import timezone
tz = timezone('EST')
datetime.now(tz)
## this returns a datetime object pointing to right now
## according to the timezone info object handed in as the tz variable.
或者,您可以定义自己的 datetime
对象并将 tz
作为 tzinfo
传递,如下所示:
datetime(2016, 3, 30, 11, 13, 24, tzinfo=tz)
关于python - 如何让python显示当前时间(东部时间),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11710469/