2.10 Representing Text
Unicode
- Python uses Unicode to represent every possible character as a unique number, known as a code point
- Ex: The character 'G' has the code point decimal value of 71
Escape Sequences
- ** is a term that the interpreter recognizes as the start to a special character, like \n for newline**.
- These two character sequences are escape sequences
Raw strings and converting text
- Escape sequences can be ignored using a raw string
- A raw string is created by adding an 'r' before a string literal, as in r'this is a raw string\'', which would output as this is a raw string\'
- ord() returns the encoded integer value for the first character of a string
- chr() does the reverse, gives the character for the encoded integer given
Formatting text