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 " 



Get Help

Comments

Popular posts from this blog

How To Create .ENV File in Python

Create a Large file for Test Data Processing using Python

How to solve the Liner Equation using Python