如何在中欧找到合适的时区?

2024-05-15 22:19:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我住在荷兰,那里使用CET和CEST。 运行JavaScript,我的笔记本电脑上确实有这些时区。你知道吗

然而,使用Python(2.7,3.6,3.7)时,我会浑身湿透。 这是不正确的,因为在这些地区的国家(如大布里坦),时钟显示一个小时前(这是相当合乎逻辑的,地球转向东)。你知道吗

为什么会出现这种偏差?我该如何纠正?你知道吗

[编辑]

import time
print (time.tzname)

结果:

('W. Europe Standard Time', 'W. Europe Daylight Time')

我希望:

('Central European Standard Time', 'Central European Daylight Time')

我没有使用pytz或任何不随发行版提供的lib。你知道吗


Tags: time国家javascript地区standard笔记本电脑centraleuropean
1条回答
网友
1楼 · 发布于 2024-05-15 22:19:56

您可能需要检查环境变量。例如,在我的Debian Linux上:

$ python3 -c "import time; print (time.tzname)"
('CET', 'CEST')

但是:

$ TZ=WET python3 -c "import time; print (time.tzname)"
('WET', 'WEST')

相关问题 更多 >