The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

URL Encode A String In Python

TODO: Pull subtitle into page object

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

code_start_default_section code_end_default_section
Results
The+quick+brown+fox

More details in the docs:

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

URL Encode A String In Python

-- p

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

-- code/
-- python

import urllib.parse

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

print(url_string)

-- /code

-- results/

The%20quick%20brown%20fox

-- /results

-- p

There is also this one which uses `+` for spaces instead of `%20`:

-- code/
-- python

import urllib.parse

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

print(url_string)

-- /code

-- results/

The+quick+brown+fox

-- /results

-- p

More details in <<link|the docs|https://docs.python.org/3/library/urllib.parse.html#urllib.parse.quote>>:


-- categories
-- Python
-- WebDev 

-- metadata
-- date: 2021-09-06 11:26:23
-- id: 20eor7yo
-- status: published
-- type: post
-- SCRUBBED_NEO: false
-- site: aws