Encode/Decode in Python3
- tags
- Python
Decoding #
Decode(v):convert (a coded message) into intelligible language. From this definition it means, in context of python, to convert a string of bytes(coded) to Unicode(intelligible).
In python3, strings are already decoded with Unicode. ref.
- More about encoding/decoding in context of Unicode is found in there.
There is no string without encoding #
If you followed the discussion so far, you probably already picked up on a crucial point about saving and reading text on a computer: Having a string without knowing its encoding makes no sense at all. ref
Encoding #
decoded_str = u"æøå" # intelligible text
decoded_str.encode('utf8')
b'\xc3\xa6\xc3\xb8\xc3\xa5'