广州linux

当前位置:   网站首页 >> python

python脚本问题AttributeError: 'module' object has no attribute 'urlopen'

 

今天打开脚本,出现错误,提示有urllib 于是用urllib2.urlopen('').read()输出,也是这样的错误。

Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>

Traceback (most recent call last):
  File "D:\Desktop\urllib.py", line 1, in <module>
    import urllib2
  File "C:\Python27\lib\urllib2.py", line 111, in <module>
    from urllib import (unwrap, unquote, splittype, splithost, quote,
  File "D:\Desktop\urllib.py", line 3, in <module>
    content_stream = urllib2.urlopen("http://www.baidu.com")
AttributeError: 'module' object has no attribute 'urlopen'
>>>

不能运行,百度搜索无果,重装python几次无果。把名字改了,问题解决

因为有个模块叫urllib,脚本叫这个名字,它把脚本当成这个模块了

尼玛python啃爹,我拍你婶


发表我的评论

Hi,您需要填写昵称和邮箱!

  • 必填项