urllib.parse.quote()
urllib.parse.quote() is a Python function in the Urllib Module category. Percent-encodes a string for use in URLs. The syntax is urllib.parse.quote(string, safe="/", encoding=None, errors=None). Parameters: string, safe. Returns: Encoded string. A typical example: from urllib.parse import quote
quote("hello world") # "hello%20world"
quote("a/b", safe="") # "a%2Fb". A close sibling is urllib.request.urlopen(), which opens a URL for reading (like GET request). Returns a file-like response object. A close sibling is urllib.request.Request(), which creates an HTTP request with custom headers and method. A close sibling is urllib.parse.urlparse(), which parses a URL into its components (scheme, netloc, path, params, query, fragment). A close sibling is urllib.parse.urlencode(), which encodes dictionary or sequence of pairs into a URL query string. More about this category: URL handling — request, parse, urlopen, urlparse, urlencode, quote. Related Urllib Module entries: urllib.request.urlopen(), urllib.request.Request(), urllib.parse.urlparse(), urllib.parse.urlencode(), urllib.parse.urljoin(), urllib.parse.unquote(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.