http资源作为随机访问类文件对象
httpio的Python项目详细描述
http资源作为随机访问文件类对象
httpio是一个小的python库,允许您访问文件 作为file-like对象(也就是说 支持标准库的BufferedIOBase接口 类)。它与中的urllib和requests等库不同 它支持seek()(移动内部指针),并且 该read()使用Range头集发出请求。它也 支持使用可配置的块大小缓存内容,并将 尽可能重用TCP连接。
安装
使用pip安装httpio:
$ pip install httpio
用法
importzipfileimporthttpiourl="http://some/large/file.zip"withhttpio.open(url)asfp:zf=zipfile.ZipFile(fp)print(zf.namelist())
单元测试
单元测试提供了由 图书馆。它们可以使用
$ python -m unittest discover -s tests
或者提供一个tox.ini文件,允许在其中运行测试 使用tox工具的虚拟环境:
$ tox