Jun 152014
 Posted by on June 15, 2014 at 5:23 pm Python, Tutorials Tagged with: ,  Add comments

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

© Incase of any copyright infringements please check copyrights page for faster resolutions.

Leave a Reply

Show Buttons
Hide Buttons