Skip to main content

urlencode

Escape a value for use in a URL.

The safe parameter determines the characters which should not be escaped by Python's quote() function. If not provided, use the default safe characters (but an empty string can be provided when all characters should be escaped).

def urlencode(
value: string,
safe: string = None
) - > string

Escape a value for use in a URL. The safe parameter determines the characters which should not be escaped by Python's quote() function. If not provided, use the default safe characters (but an empty string can be provided when all characters should be escaped).

Parameters

NameTypeDescription
valuestringThe input string to be escaped for use in a URL.
safestring = NoneA string containing characters that should not be escaped; if an empty string is provided, all characters will be escaped.

Returns

TypeDescription
stringThe URL-encoded version of the input string, with special characters replaced by their percent-encoded equivalents.