【发布时间】:2016-05-05 14:54:05
【问题描述】:
看起来很奇怪,但我找不到在 Python 中使用 Pandas/pytz 查找本地时区的简单方法。
我能做到:
>>> pd.Timestamp('now', tz='utc').isoformat()
Out[47]: '2016-01-28T09:36:35.604000+00:00'
>>> pd.Timestamp('now').isoformat()
Out[48]: '2016-01-28T10:36:41.830000'
>>> pd.Timestamp('now').tz_localize('utc') - pd.Timestamp('now', tz='utc')
Out[49]: Timedelta('0 days 01:00:00')
这会给我时区,但这可能不是最好的方法...... pytz 或 pandas 中是否有获取系统时区的命令? (最好在 python 2.7 中)
【问题讨论】:
-
相关的,如果不是被骗的话:Python: Figure out local timezone
-
fuxking python 没有内置的方法来做到这一点。
标签: python python-2.7 pandas timezone-offset pytz