dashwood.net -

Ryan Stefan's Micro Blog

Managing URLs with Python

Dec 232018
import urllib

params = urllib.parse.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
f = urllib.urlopen("http://www.musi-cal.com/cgi-bin/query?%s" % params)


print(urllib.parse.quote_plus("+kite+/"))

%2Bkite%2B%2F


Note that it's different for python2 -> urllib.quote_plus() & urllib.urlencode()

Comments