Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

URL Encode A String In Python

This code encodes (aka quotes) a string for use in a url query string path :

python
import urllib.parse

string = "The quick brown fox"
url_string = urllib.parse.quote(string)

print(url_string)
results start

There is also this one which uses [TODO: Code shorthand span ] for spaces instead of ` %20 ` :

python
import urllib.parse

string = "The quick brown fox"
url_string = urllib.parse.quote_plus(string)

print(url_string)
results start

More details in the docs :