How to urlencode a query string in Python?

873    Asked by arun_3288 in Python , Asked on Mar 3, 2021
Answered by Arun Singh

Simply make a word reference with your boundaries to be encoded in the urlencode function of urrlib module. e.g:


For python 2:

import urllib

d = {'a': 'b', 'c': 'd'};

urllib.urlencode(d)

For Python 3

import urllib

d = {'a': 'b', 'c': 'd'};

urllib.parse.urlencode(d)



Your Answer

Interviews

Parent Categories