Escape sequence in Python

The escape sequence is used to insert the tab, the newline, the backspace, and other special characters into your code. They give you greater control and flexibility to format your statements and code:

Escape Sequence Meaning
b Backspace
a Sound system bell
n Newline
t Horizontal tab
The character
' Single quotation mark
" Double quotation mark
print 'a' print 'tHermit' print "i know , they are 'great'"

The output is as follows:

C:pydev>python hello.pyHermiti know , they are 'great'

The preceding code executes with a beep sound. If you did not hear the beep sound, check your speakers.

Get Learn Python in 7 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.