Python Escape Characters
Concept
To insert characters that are illegal in a string, use an escape character.
An escape character is a backslash \ followed by the character you want to insert.
Suppose you want to write Python's Blog then you need an escape character.
Code
>>> print('I like tea \ coffee')
SyntaxError: invalid syntax
To solve this issue we need to put one '\' over there and it will work as an escape character.
Example:
>>> print('Python\'s Blog')
Python's Blog
>>> print('I like tea \\ coffee' )
I like tea \ coffee
>>> print('I Love \" Pythom \" ')
I Love " Pythom "
Comments
Post a Comment