I am facing a problem with urllib.url_encode in python. Bets explained with some code:
>>> from urllib import urlencode
>>> params = {\'p\' :
It is simpler in Python 3:
urllib.parse.urlencode(params, safe='|')
Convert a mapping object or a sequence of two-element tuples to a “percent-encoded” string[...]
The urlencode() method is acting as expected. If you want to prevent the encoding then you can first encode the entire object and then replace the encoded characters with pipes.
>>> u = urlencode(params)
>>> u.replace('%7C', '|')
'p=1+2+3+4+5%266&l=ab|cd|ef'