符合rfc 3986,支持unicode,与方案无关的urlparse替换

uritools的Python项目详细描述


此模块定义了符合RFC 3986的替换 python 2.7标准库的常用函数 urlparse和python 3urllib.parse模块。

>>> fromuritoolsimporturicompose,urijoin,urisplit,uriunsplit>>> uricompose(scheme='foo',host='example.com',port=8042,... path='/over/there',query={'name':'ferret'},... fragment='nose')'foo://example.com:8042/over/there?name=ferret#nose'
>>> parts=urisplit(_)>>> parts.scheme'foo'
>>> parts.authority'example.com:8042'
>>> parts.getport(default=80)8042
>>> parts.getquerydict().get('name')['ferret']
>>> urijoin(uriunsplit(parts),'/right/here?name=swallow#beak')'foo://example.com:8042/right/here?name=swallow#beak'

出于各种原因,python 2urlparse模块不兼容 使用当前的Internet标准,不包括Unicode支持,以及 对于专有的uri方案通常是不可用的。Python3 urllib.parse改进了对Unicode的支持,但其他问题仍然存在 留下来。如Lib/urllib/parse.py

RFC 3986 is considered the current standard and any future changes
to urlparse module should conform with it.  The urlparse module is
currently not entirely compliant with this RFC due to defacto
scenarios for parsing, and for backward compatibility purposes,
some parsing quirks from older RFCs are retained.

本模块旨在为 在urlparseurllib.parse,加上额外的函数,可以方便地编写 来自各个组件的uri。

安装

使用pip安装uritools:

pip install uritools

许可证

版权所有(c)2014-2018 Thomas Kemmer。

根据MIT License授权。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java为什么stripVersion不能在带有mojo依赖项的mavendependencyplugin上工作   java存储具有不同功能的大量对象   java Spring MockMvc自定义验证器未在Spring容器中注册/调用   javascript程序编辑实体而不是添加   C++如何在java上检索图形卡信息?   java如何在没有方法参数的方法上使用@cacheable注释的键   java如何获取特定用户或学生的JSON   java可序列化AjaxRequestTarget   java Tomcat 8禁用分块编码过滤器   java这个简单的Swingbase类是线程安全的吗?   java调用Gdi32。使用JNA获取对象   如何使用来自其他类Java Android onClick的方法?   json序列化已经有了id(java.lang.String)的POJO   java使用jsp上传多个文件?   java有没有办法为Android项目在EclipseIndigo上设置JVM参数?   Eclipse中的java,为什么它告诉我添加一个已经存在的分号?   Java中的正则表达式拆分行   Java:在单行中赋值