AttributeError在线程中使用time.strptime()时,我写的东西抛出了很多异常.这似乎只发生在Windows上(不是在Linux上),但无论如何,在'googling中,似乎time.strptime()不被认为是线程安全的.
有没有更好的方法从字符串创建日期时间对象?当前代码如下:
val = DateFromTicks(mktime(strptime(val, '%B %d, %Y')))
Run Code Online (Sandbox Code Playgroud)
但是,这会产生异常,因为它在一个线程内运行.
谢谢!
Rom*_*net 18
这个bug的另一个解决方法是,您可以_strptime手动导入,以及日期时间
import _strptime
from datetime import datetime
# then, in threaded block
datetime.strptime(date, format)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5981 次 |
| 最近记录: |