码迷,mamicode.com
首页 > 编程语言 > 详细

Python3 urlparse

时间:2016-11-11 20:36:45      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:cas   query   pat   host name   nal   param   html   word   pytho   

>>> from urllib.parse import urlparse
>>> o = urlparse(http://www.cwi.nl:80/%7Eguido/Python.html)
>>> o   
ParseResult(scheme=http, netloc=www.cwi.nl:80, path=/%7Eguido/Python.html,
            params=‘‘, query=‘‘, fragment=‘‘)
>>> o.scheme
http
>>> o.port
80
>>> o.geturl()
http://www.cwi.nl:80/%7Eguido/Python.html
>>> from urllib.parse import urlparse
>>> urlparse(//www.cwi.nl:80/%7Eguido/Python.html)
ParseResult(scheme=‘‘, netloc=www.cwi.nl:80, path=/%7Eguido/Python.html,
           params=‘‘, query=‘‘, fragment=‘‘)
>>> urlparse(www.cwi.nl/%7Eguido/Python.html)
ParseResult(scheme=‘‘, netloc=‘‘, path=www.cwi.nl/%7Eguido/Python.html,
           params=‘‘, query=‘‘, fragment=‘‘)
>>> urlparse(help/Python.html)
ParseResult(scheme=‘‘, netloc=‘‘, path=help/Python.html, params=‘‘,
           query=‘‘, fragment=‘‘)
AttributeIndexValueValue if not present
scheme 0 URL scheme specifier scheme parameter
netloc 1 Network location part empty string
path 2 Hierarchical path empty string
params 3 Parameters for last path element empty string
query 4 Query component empty string
fragment 5 Fragment identifier empty string
username   User name None
password   Password None
hostname   Host name (lower case) None
port   Port number as integer, if present None

 

来源:https://docs.python.org/3/library/urllib.parse.html?highlight=urlparse#urllib.parse.urlparse

Python3 urlparse

标签:cas   query   pat   host name   nal   param   html   word   pytho   

原文地址:http://www.cnblogs.com/itlqs/p/6055365.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!