python url解析

    >>> url="http://localhost/test.py?a=hello&b=world "  
    >>> result=urlparse.urlparse(url)  
    >>> result  
    ParseResult(scheme='http', netloc='localhost', path='/test.py', params='', query='a=hello&b=world ', fragment='')  
    >>> urlparse.parse_qs(result.query,True)  
    {'a': ['hello'], 'b': ['world ']}  
    >>> params=urlparse.parse_qs(result.query,True)  
    >>> params  
    {'a': ['hello'], 'b': ['world ']}  
    >>> params['a'],params['b']  
    (['hello'], ['world '])  

 

posted on 2014-04-29 15:19  雨渐渐  阅读(336)  评论(0编辑  收藏  举报

导航