Python 3.2不会导入cookielib

Sne*_*e38 4 python

我到处寻找这个,但是找不到答案.我检查了我的python版本,它是版本3.2.当我尝试导入时cookielib收到:

ImportError: No module named cookielib

我已经看到它在Python 3.0中被重命名为 http.cookiejar并且它将自动导入cookielib.

我想也许在我的python配置中有一些疯狂的错误,所以我想我应该尝试http.cookiejar像这样导入import http.cookiejar.这并不是全部,我得到并且错误:

EOFError: EOF read where not expected.

这不是我预期的错误,因为import http.cookies进口就好了.

有没有人能解决这个问题?我在俯瞰什么?

完全错误:

Traceback (most recent call last):
  File "C:\Users\Spencer\Downloads\selenium-2.20.0.tar\selenium-2.20.0\selenium-2.20.0\test", line 1, in <module>
    import urllib.request, urllib.parse, http.cookiejar
EOFError: EOF read where not expected
Run Code Online (Sandbox Code Playgroud)

phi*_*hag 9

自动重命名,如果你使用的业务仅适用2to3的.因此,你必须import http.cookiejar.

EOFError: EOF read where not expected只有Python编组才会抛出错误.最有可能的是,这是由Python 3.3中修复的竞争条件引起的,其中多个进程试图同时写入pyc文件.删除所有.pyc文件可能是一种解决方法.


小智 8

try:
    import cookielib
except:
    import http.cookiejar
    cookielib = http.cookiejar
Run Code Online (Sandbox Code Playgroud)