["python","dictionary","url-parameters"]
Python Dictionary to URL Parameters

I am trying to convert a Python dictionary to a string for use as URL parameters. I am sure that there is a better, more Pythonic way of doing this. What is it? x = "" for key, val in {'a':'A', 'b':'B'}.items(): x += "%s=%s&" %(key,val) x = x[:-1]
Here is the correct way of using it in Python 3. from urllib.parse import urlencode params = {'a':'A', 'b':'B'} print(urlencode(params))