requests 是 Python 的一个 HTTP 客户端库,跟 urllib,urllib2 类似,不过 requests 的优势在于使用简单,相同一个功能,用 requests 实现起来代码量要少很多。毕竟官方文档都很直白的说:
python 的标准库 urllib2 提供了大部分需要的 HTTP 功能,但是 API 太逆天了,一个简单的功能就需要一大堆代码。
所以,使用 requests 方便的多。
参考pip在线安装
G:\Projects\github\hmac-auth-java-sdk\hmac-auth\jars>pip2 install requests
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in indexes: https://mirrors.aliyun.com/pypi/simple
Requirement already satisfied: requests in f:\python27\lib\site-packages (2.24.0)
Requirement already satisfied: idna<3,>=2.5 in f:\python27\lib\site-packages (from requests) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in f:\python27\lib\site-packages (from requests) (2020.6.20)
Requirement already satisfied: chardet<4,>=3.0.2 in f:\python27\lib\site-packages (from requests) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in f:\python27\lib\site-packages (from requests) (1.25.9)
WARNING: You are using pip version 19.2.3, however version 20.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
下载离线安装包
https://files.pythonhosted.org/packages/da/67/672b422d9daf07365259958912ba533a0ecab839d4084c487a5fe9a5405f/requests-2.24.0.tar.gz
随后解压并准备安装
错误的离线安装命令
F:\Python27\python.exe F:\Programs\requests-2.24.0\requests-2.24.0\setup.py install
报错readme.md找不到
G:\Projects\github\hmac-auth-java-sdk\hmac-auth\jars