iNTERFACEWARE Products Manual > Learning Center > Learning Python > Working With Strings > Escape Sequences and Raw Strings |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
In strings, a backslash \ character followed by one or more characters is used to represent any character that cannot be displayed in a string, such as:
A sequence of characters that starts with a backslash is known as an escape sequence.
The following table lists some of the most commonly used escape sequences in Python.
If you want to create multi-line strings, and do not want to use the \n escape sequence, you can enclose your string in three single quote ''' or three double-quote """ characters:
In these strings, you do not need to include the backslash character \ before either the ' character or the " character.
If you want to create a string that contains backslashes, and you do not want Python to try to interpret these backslashes as escape sequences, you can create a raw string. To create a raw string, specify an r character before the opening single quote ' or double quote " character that encloses the string:
You can also create raw multi-line strings:
|