python-3.x - python : Attribute Error: 'module' object has no attribute 'request'

标签 python-3.x attributeerror

我对 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/

相关文章:

python - 无法解封

Python Tkinter : How to disable window showing in taskbar?

python - 从服务器获取响应

python:提取列值大于3的行

python - AttributeError: 'NoneType'对象没有属性 'shape'/从多个轮廓框转换为单数

python - 尝试调用 pyusb 中的后端模块时出错。 "AttributeError: ' 模块的对象没有属性 'backend' "

python - AttributeError: 'NoneType' 对象在 tbody 中没有属性 'find'

Python 3 : EOF when reading a line (Visual Studio Code)

python - AttributeError: 'Element' 对象没有属性 'findAll'

python - 为什么我会收到 discord.py AttributeError : 'str' object has no attribute 'trigger_typing'