Loading...
Python

Escape Character

In String literals we can use escape characters to associate a special meaning.
The following are various important escape characters in Python

  1. \n==>New Line
  2. \t==>Horizontal Tab
  3. \r==>Carriage Return
  4. \b==>Back Space
  5. \’==>Single Quote
  6. |v==>Vertical Tab
  7. \\==>Back Slash Symbol
  8. \f==>Form Feed

Example:
>>>s=”Webnoid\nschools”
>>>print(s)
Webnoid
school
>>>s=”Webnoid\tschool”
Webnoid     school
>>>s=”this is “symbol”
File”<stdin>”, line 1
s=”this is “symbol”

SyntaxError: invalid syntax
>>>s=”This is ” symbol”
>>>print(s)
This is ” symbol

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *