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 '])  

 

你可能感兴趣的:(python)