Formatting
Table of contents
Description
F-strings have an f at the beginning and curly braces containing expressions that will be replaced with their values. Use f-strings to format strings, ints, floats, etc.
- Python Docs: Formatted String Literals, Escape Sequences
Example
Escape Sequences
Escape sequences allow you to include symbols and characters inside string literals using a backslash. As an example, You cannot use a contraction with an apostrophe inside a string enclosed in single quotes. You would “escape” that symbol with a backslash:
Escape Sequence | Symbol |
---|---|
\’ | Single Quote |
\” | Double Quote |
\t | Tab |
\n | Newline |
\\ | Backslash |