Open this example in the interactive library
Source code
from urllib.parse import urlencode
print(urlencode({'q':'hello world','page':2}))Sample output
q=hello+world&page=2

Build a URL query string. A self-contained example using the Python standard library.
Open this example in the interactive library
from urllib.parse import urlencode
print(urlencode({'q':'hello world','page':2}))q=hello+world&page=2