Handle Unicode text, emoji, encoding, normalization, code points, and safe storage.
Lessons
Convert between str and bytes explicitly.
Python encode() & decode() is easiest to learn by reading the example, changing it, and observing the result.
text = "café 😀"
# str is Unicode; encode to bytes explicitly
data = text.encode("utf-8")
print(len(text), "characters") # 6
print(len(data), "bytes") # 10
# bytes back to str
print(data.decode("utf-8"))
# Always open files with an explicit encoding
# open("notes.txt", "w", encoding="utf-8")Practice the Python encode() & decode() example in a small scratch file, then explain what changed and why.