python 的urlparse学习

Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> url = 'http://www.something.com:1234/foo/index.html?name=kzc&age=29#second'
>>> import urlparse
>>> up=urlparse.urlparse
>>> up=urlparse.urlparse(url)
>>> up.scheme
'http'
>>> up.hostname
'www.something.com'
>>> up.port
1234
>>> up.path
'/foo/index.html'
>>> up.query
'name=kzc&age=29'
>>> up.fragment
'second'
>>> up.netloc
'www.something.com:1234'
>>>

posted on 2017-05-25 16:42  sugus33  阅读(114)  评论(0编辑  收藏  举报