为什么python时间有61秒

2024-04-25 01:03:47 发布

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

有人注意到Python datetime中秒的间隔是[00,61] 见本页底部的表格。 http://docs.python.org/library/datetime.html#strftime-strptime-behavior

为什么?在


Tags: orghttpdocsdatetime间隔htmllibrary表格
3条回答

可能是因为leap seconds。在

没有所谓的双闰秒。一分钟不可能有62秒。59,是的。60,是的。61,是的。62号,没有

http://www.monkey.org/openbsd/archive2/tech/199905/msg00031.html

答案就在下面一页:

The range really is 0 to 61; according to the Posix standard this accounts for leap seconds and the (very rare) double leap seconds. The time module may produce and does accept leap seconds since it is based on the Posix standard, but the datetime module does not accept leap seconds in strptime() input nor will it produce them in strftime() output.

这的确是一个有趣的行为。在

相关问题 更多 >