相关疑难解决方法(0)

1984年3月16日发生了什么?

我想弄清楚1984年3月16日有什么特别之处.在我使用的虚拟机上(没有什么特别之处),Python(以及PyPy)在尝试使用mktime时崩溃了,这似乎是一个非常合理的时间结构.

$ pypy
Python 2.7.3 (f66246c46ca30b26a5c73e4cc95dd6235c966b8f, Jul 30 2013, 09:27:06)
[PyPy 2.0.2 with GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>> import time
>>>> time.mktime((1984,3,16,0,0,0,0,0,0))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: mktime argument out of range
>>>> time.mktime((1984,3,15,0,0,0,0,0,0))
448156800.0
>>>> time.mktime((1984,3,17,0,0,0,0,0,0))
448326000.0
>>>> time.mktime((1984,3,16,0,0,0,0,0,0))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: mktime argument out of range
>>>> …
Run Code Online (Sandbox Code Playgroud)

python timezone pypy mktime

11
推荐指数
2
解决办法
593
查看次数

OSError:[Errno 22]使用 datetime.strptime 时参数无效

我测试了以下代码:

date_string = "16:30"
date = datetime.strptime(date_string, "%H:%M")
timestamp = datetime.timestamp(date)
print(timestamp)
Run Code Online (Sandbox Code Playgroud)

但我收到错误:

OSError: [Errno 22] 参数无效

在此输入图像描述

我应该怎么做才能获取时间的时间戳?

python datetime timestamp

1
推荐指数
1
解决办法
2272
查看次数

标签 统计

python ×2

datetime ×1

mktime ×1

pypy ×1

timestamp ×1

timezone ×1