Python Glossary Русский

Python 3.2+urllib.parseterm

urllib.parse.SplitResultBytes

parse results

The result of urlsplit() for bytes: the same five fields as SplitResult, but the fields are byte strings.

Syntax

SplitResultBytes(scheme, netloc, path, query, fragment)

The argument decides the result type: bytes in, SplitResultBytes out. hostname is bytes too, while port is an int. decode() gives a SplitResult and SplitResult.encode() goes back; both default to ASCII.

Examples

from urllib.parse import urlsplit
r = urlsplit(b'http://Host:81/p')
print(r.hostname, r.port)  # → b'host' 81
print(r.decode().path)  # → /p

See also

Open in the full glossarydocs.python.orgReport an inaccuracy