为什么time.timezone是负值,尽管我的tz是UTC+5.30



很抱歉问这个基本问题。但我在python的";"时间和时区";计算。我认为这是因为,python中有太多的解决方案,无法计算时间。

我的疑问是:

import time
time.time()
1661680722.0567589
time.timezone
-19800

我的时区是UTC+5.30。我期望时间。时间等于utc时间。因此,time.timezone应该是一个相当于5.30小时的正值。不是吗?为什么它会变成负值?

根据文档time.timezone返回:

The offset of the local (non-DST) timezone, in seconds west of UTC (negative in most of Western Europe, positive in the US, zero in the UK). See note below.

因此,它返回负值是有道理的,因为19800秒实际上是5.5小时。

最新更新