Character and Text Representation

In this you will learn how to represent characters and text in Python.

Character representation

We talked about encoding characters with ASCII and Unicode in the lesson on number and letter representation. Now, let’s see these encoding methods in Python. An English letter can easily be represented using 1 byte. In the code snippet below, we are finding the length of a UTF-8 encoded character that has the value A. Run to verify that it is indeed 1 byte.

Note: The function encode forces the use of a certain character encoding scheme like UTF-8.

Get hands-on with 1200+ tech skills courses.