codecs¶
The codecs module provides a consistent API for encoding strings (or objects) into different representations. The following encodeings are supported:
base64
hex
json
punycode
utf8
-
encode
(encoding, data)¶ Encodes the given data using the desired encoding.
Arguments: - encoding – The desired encoding. (Must be one of the supported encodings)
- data – Value which will be encoded.
Returns: A string with the encoded data.
-
decode
(encoding, data)¶ Decodes the given data using the desired encoding.
Arguments: - encoding – The desired encoding. (Must be one of the supported encodings)
- data – Value which will be decoded.
Returns: The decoded object.