Python Escape Sequences Quick View


Python allows for certain characters such as a Tab or Carriage Return to be embedded within strings to allow extra control over printing. There are also times that you have a string that requires a single or double quote that would normally cause problems.
For example, let’s say you decided to create a string using the single quote as the string delimiter. Without using an escape sequence you can’t have a single quote within the string. While you could use double quotes to delimit the string, that might be an issue.

>>> test = ‘This is a test of the \’ (single quote) character’
>>> test
“This is a test of the ‘ (single quote) character”
The escape sequence starts with a backslash (\) character then followed by a character. This will be interpreted by Python as a special character.

Escape Characters Python

Escape Characters Python


More details about escape sequences can be found here

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.