Heim  >  Fragen und Antworten  >  Hauptteil

python中mktime的问题?

import time
t=time.strptime("1969-Sep-23 00:00:00",'%Y-%b-%d %H:%M:%S')
s=time.mktime(t)

错误提示:OverflowError:mktime argument out of range.

如果把时间改成1970-Sep-23 00:00:00 就不会出现错误。

为什么?

PHPzPHPz2742 Tage vor927

Antworte allen(2)Ich werde antworten

  • 大家讲道理

    大家讲道理2017-04-17 15:01:54

    时间戳就是从1970开始的,最早到1970年

    Antwort
    0
  • 迷茫

    迷茫2017-04-17 15:01:54

    我这里没有报错,而是返回了一个负数。相关信息:Linux x86_64, Python 2.7.9 & 3.4.3, glibc 2.21。你也应该提供这些信息。

    Antwort
    0
  • StornierenAntwort