python常用转义符

对于python常用转义符的一个总结。

在行尾时作为续行符

1
2
print("This how '' appear in the end of a line
happens")

1
This how '' appear in the end of a line happens

反斜杠符号

1
print("\")

1

’单引号

1
print('I'm very happy')

1
I'm very happy

“双引号

1
print("I"m very happy")

1
I"m very happy

a响铃

1
print("This is how it works a") 

1
This is how it works 

b退格,光标位置回退一位

1
2
print("This is how it worksb") # 将前面的替换为空格
print("This is how it worksbb")

1
2
This is how it works
This is how it works

n回车,光标在下一行

1
print("Hellonworld!")

1
2
Hello
world!

r回车,光标位置回退到本行开头

1
print("Hellorworld!")

1
world!

f换页,用于打印时

v纵向制表符

1
print("vHello, world!")

1
Hello, world!

t横向制表符

1
print("tHello, world!")

1
Hello, world!