On this page
codecs.decode
Prev: codecs.CodecInfo | Up: codecs | Next: codecs.encode
Rel: codecs.backslashreplace_errors, codecs.Codec, codecs.CodecInfo, codecs.encode
Ref: docs.python.org — codecs.decode
Tags: #public #python3 #stdlib #codecs
Import
import codecs
from codecs import decode
Signature & Overview
codecs.decode(obj, encoding='utf-8', errors='strict')
Decodes obj using the codec registered for encoding.
Usage
import codecs
assert codecs.decode(b"6869", "hex") == b"hi"
assert codecs.decode("uryyb", "rot_13") == "hello"
Gotchas
- Supports non-text codecs (
hex,rot_13,unicode_escape) thatbytes.decode()rejects.
REPL Inspect
from codecs import decode
help(decode)
Linked from
- tuts/python3/stdlib_module/codecs
- tuts/python3/stdlib_module/codecs/backslashreplace_errors
- tuts/python3/stdlib_module/codecs/Codec
- tuts/python3/stdlib_module/codecs/CodecInfo
- tuts/python3/stdlib_module/codecs/encode
- tuts/python3/stdlib_module/codecs/EncodedFile
- tuts/python3/stdlib_module/codecs/getdecoder
- tuts/python3/stdlib_module/codecs/getencoder
- tuts/python3/stdlib_module/codecs/getincrementaldecoder
- tuts/python3/stdlib_module/codecs/getincrementalencoder
- tuts/python3/stdlib_module/codecs/getreader
- tuts/python3/stdlib_module/codecs/getwriter
- tuts/python3/stdlib_module/codecs/ignore_errors
- tuts/python3/stdlib_module/codecs/IncrementalDecoder
- tuts/python3/stdlib_module/codecs/IncrementalEncoder
- tuts/python3/stdlib_module/codecs/iterdecode
- tuts/python3/stdlib_module/codecs/iterencode
- tuts/python3/stdlib_module/codecs/lookup
- tuts/python3/stdlib_module/codecs/lookup_error
- tuts/python3/stdlib_module/codecs/namereplace_errors
- tuts/python3/stdlib_module/codecs/open
- tuts/python3/stdlib_module/codecs/register
- tuts/python3/stdlib_module/codecs/register_error
- tuts/python3/stdlib_module/codecs/replace_errors
- tuts/python3/stdlib_module/codecs/StreamReader
- tuts/python3/stdlib_module/codecs/StreamReaderWriter
- tuts/python3/stdlib_module/codecs/StreamRecoder
- tuts/python3/stdlib_module/codecs/StreamWriter
- tuts/python3/stdlib_module/codecs/strict_errors
- tuts/python3/stdlib_module/codecs/xmlcharrefreplace_errors
Related notes
- tuts/python3/stdlib_module/codecs/backslashreplace_errors Linked here; links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/Codec Linked here; links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/CodecInfo Linked here; links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/encode Linked here; links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/codecs/EncodedFile links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/getdecoder links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/getencoder links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/getincrementaldecoder links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/getincrementalencoder links to this page; shared tags: #codecs, #stdlib