简体   繁体   English

Python3 错误:AttributeError:模块 'urllib' 没有属性 'request'

[英]Python3 error : AttributeError: module 'urllib' has no attribute 'request'

I am trying to run a script in python3 (tried with 3.7.4 and 3.8.0) which uses urllib.request and urllib.error .我正在尝试在 python3 中运行一个脚本(尝试使用 3.7.4 和 3.8.0),它使用urllib.requesturllib.error

I tried importing in the following ways:我尝试通过以下方式导入:

import urllib

and

from urllib import request

but in both the above cases I get error:但在上述两种情况下,我都会收到错误:

AttributeError: module 'urllib' has no attribute 'request'

I haven't installed anything related to urllib as it comes with python3我没有安装任何与urllib相关的东西,因为它带有 python3

Please suggest how should this be imported, thanks!请建议如何导入,谢谢!

Worked with following import:使用以下导入:

import urllib.request

Since urllib is a folder and request is a file inside urllib, you should use:由于 urllib 是一个文件夹,而 request 是 urllib 中的一个文件,你应该使用:

import urllib.request as request

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError: 'tuple' 对象没有属性 'timeout' - Python3 中的 urllib 请求 - AttributeError: 'tuple' object has no attribute 'timeout' - urllib request in Python3 urllib模块错误! AttributeError:'module'对象没有属性'request' - urllib module error! AttributeError: 'module' object has no attribute 'request' Pycharm python AttributeError:模块'urllib3'没有属性'Request' - Pycharm python AttributeError: module 'urllib3' has no attribute 'Request' AttributeError:模块“urllib.request”没有属性“用户” - AttributeError: module 'urllib.request' has no attribute 'user' AttributeError-module 'urllib.request' 没有属性 'META' - AttributeError-module 'urllib.request' has no attribute 'META' AttributeError: 模块 'urllib3' 在 python 中没有属性 'urlopen' - AttributeError: module 'urllib3' has no attribute 'urlopen' in python AttributeError: 模块 'urllib3' 没有属性 'urlretrieve' - AttributeError: module 'urllib3' has no attribute 'urlretrieve' AttributeError: 模块 'urllib' 没有属性 'parse' - AttributeError: module 'urllib' has no attribute 'parse' Python; urllib 错误:AttributeError: 'bytes' object 没有属性 'read' - Python; urllib error: AttributeError: 'bytes' object has no attribute 'read' Python3(anaconda)中的tkinter,“ AttributeError:模块'tkinter'没有属性'Tk'” - tkinter in Python3 (anaconda), “AttributeError: module 'tkinter' has no attribute 'Tk'”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM