我对 python 非常陌生,正在练习从 url 加载数据集。
运行以下代码时:
在[1]中:myUrl = "http://aima.cs.berkeley.edu/data/iris.csv "
在[2]中: urlRequest = urllib.request.Request(myUrl)
我收到此错误:
File "", line 1, in urlRequest = urllib.request.Request(myUrl)
AttributeError: 'module' object has no attribute 'request'
1) 我尝试研究此错误并尝试再次使用 import urllib3
并且导入正常。但是,当尝试请求时,我收到该错误...
2) 我尝试在 python 3.6.0 中获取“help” help("urllib3")
并得到:
No Python documentation found for 'urllib3'. Use help() to get the interactive help utility. Use help(str) for help on the str class.
3) 我搜索了 Stackoverflow 并看到了类似的问题;尝试了建议,但无法跳过该行代码...
我在这里做错了什么吗?
预先感谢您的宝贵时间
最佳答案
据我所知,“请求”不是一个包,这意味着您不能直接从中导入类。
尝试:
from urllib.request import Request
myUrl = "http://aima.cs.berkeley.edu/data/iris.csv"
urlRequest = Request(myUrl)
关于python-3.x - python : Attribute Error: 'module' object has no attribute 'request' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42440972/