Why python time has 61 seconds

后端 未结 5 2094
逝去的感伤
逝去的感伤 2021-01-04 03:57

Did anybody notice that the interval of second in Python datetime is [00,61] see the table in the bottom of this page. http://docs.python.org/library/datetime.html#strftime-

5条回答
  •  无人及你
    2021-01-04 04:48

    The answer is a little further down in the page:

    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.

    This is an interesting behavior, indeed.

提交回复
热议问题