How to escape (percent-encode) a URL with Python « SaltyCrane Blog
How to escape (percent-encode) a URL with Python
import urllib print urllib.quote_plus("http://www.yahoo.com/") print urllib.quote_plus("Kruder & Dorfmeister")Results:
http%3A%2F%2Fwww.yahoo.com%2F Kruder+%26+DorfmeisterIt is easy to be drawn to the
urlencodefunction in
the Python
urllibmodule documentation. But for simple
escaping, onlyquote_plus, or
possiblyquoteis needed. I believe this is the
appropriate solution to
Python urlencode annoyance and
O'Reilly's Amazon Hack #92.
浙公网安备 33010602011771号