Python--the use of escape characters

\: Line break input

>>> t="love ,you\
very much"
>>> t
'love ,youvery much'
>>> 

\: Output \

>>> him="love her\\"
>>> print(him)
love her\

distinguish:

>>> him="love her\\"
>>> him
'love her\\'

\ n: Line break

>>> s='love me\n'
>>> print(s)
love me

>>> 

\ a: sound a warning tone

>>> print('him\a')
him

\ b: backspace delete

>>> print('loven\bh')
loveh

but

>>> print('loven\b')
loven

'Escape single quotes

>>> print('I  \'m beautiful')
I  'm beautiful

"Escape double quotes

>>> print("name:\"colin\"")
name:"colin"

\ r Enter

for i in range(9):
    print("\r数字是:",i)

数字是: 0
数字是: 1
数字是: 2
数字是: 3
数字是: 4
数字是: 5
数字是: 6
数字是: 7
数字是: 8

\ t: horizontal tab – four spaces

>>> print("love\tyou\t")
love    you

\ v: add tabs to the vertical position

\ f: page feed, terminal page cannot be seen

\ 000: empty (one)

>>> print("love\000you")
love you

\ xyz): three-digit xyz corresponds to the character represented by ASCII octal number xyz

>>> print('\123')
S
在这里插入代码片

\ x…: Two digits ... Corresponding to ASCII two hexadecimal characters ...

>>> print("\x30")
0

\ other: output in normal format

>>> print("\love you")
\love you
Published 57 original articles · praised 54 · visits 2343

Guess you like

Origin blog.csdn.net/September_C/article/details/105230143