urllib使用

>>> filename=urllib.urlretrieve(url,r"D:\code\sogou.html")
>>> url2=r'http://www.baidu.com/!@#'
>>> urllib.quote(url2)
'http%3A//www.baidu.com/%21%40%23'
>>> urllib.quote_plus(url2)
'http%3A%2F%2Fwww.baidu.com%2F%21%40%23'
>>> urllib.unquote("http%3A//www.baidu.com/%21%40%23")
'http://www.baidu.com/!@#'
>>> urllib.unquote_plus("http%3A%2F%2Fwww.baidu.com%2F%21%40%23")
'http://www.baidu.com/!@#'
>>>

你可能感兴趣的:(Python高级编程)