Binary and Encoding Modules

encodings

Standard codec implementation package used by the codec registry. Application code normally selects a codec by name via str.encode(), bytes.decode() or codecs.lookup(), rather than importing a private implementation detail. Available platform-specific codecs can differ.

Formal Syntax & Structure

python syntaxpython
import encodings

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
import encodingsimport codecsprint(codecs.lookup("UTF-8").name)print("Hi".encode("utf-8"))
Python Reference