search

Home  >  Q&A  >  body text

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 就不会出现错误。

为什么?

PHPzPHPz2804 days ago962

reply all(2)I'll reply

  • 大家讲道理

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

    The timestamp starts from 1970, the earliest is 1970

    reply
    0
  • 迷茫

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

    I did not report an error here, but returned a negative number. Related information: Linux x86_64, Python 2.7.9 & 3.4.3, glibc 2.21. You should also provide this information.

    reply
    0
  • Cancelreply