AttributeError: 'module' 对象没有属性 'request' [英] AttributeError: 'module' object has no attribute 'request'
本文介绍了AttributeError: 'module' 对象没有属性 'request'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在 Python 3.3 中运行以下代码时:
When I run the following code in Python 3.3:
import urllib
tempfile = urllib.request.urlopen("http://yahoo.com")
我收到以下错误:
我也这样做是为了验证:
I did this too to verify:
我做错了什么?
推荐答案
urllib
模块已被拆分为多个部分,并在 Python 3 中重命名为 urllib.request
,urllib.parse
和 urllib.error
.
The urllib
module has been split into parts and renamed in Python 3 to urllib.request
, urllib.parse
, and urllib.error
.
导入 urllib.request
而不是 urllib
.
import urllib.request
这篇关于AttributeError: 'module' 对象没有属性 'request'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文