Python 3.5.1 urllib 没有属性请求 [英] Python 3.5.1 urllib has no attribute request

查看:73
本文介绍了Python 3.5.1 urllib 没有属性请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过了

import urllib.request

import urllib

我的 urllib 的路径是/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/__init__.py

The path for my urllib is /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/__init__.py

我想知道 urlopen 在哪里,还是我的 python 模块指向了错误的文件?

I am wondering where is urlopen, or is my python module pointing to the wrong file?

推荐答案

根据 ,你必须使用以下内容:

According to this, you have to use the following:

import urllib.request

原因是:

对于包,像这样,有时需要显式导入你想要的一块.这样,urllib 模块不必加载一切都只是因为你想要一小部分.

With packages, like this, you sometimes need to explicitly import the piece you want. That way, the urllib module doesn't have to load everything up just because you wanted one small part.

这篇关于Python 3.5.1 urllib 没有属性请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆