python学习2(转义符的学习)

转义符

python中有些符号有特殊作用。
换行符:\n
制表符:\t
重写:\r
回退:\b

#默认
print('hello world')
#插入换行符
print('hello\nworld')
#插入制表符
print('hello\tworld')
#插入重写
print('hello\rworld')
#插入回退
print('hello\bworld')

‘ 和 “ 还有 / 的正常使用,需要再加一个/在前面

#特殊符号的显示+\
print('\\','\"')

如果想让这些转义字符字符正常显示:需要加个R/r
(前提字符串的最后一位不能是\)

#转义符的显示(不使用)
print(r'hello\b')

效果展示:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_40551957/article/details/113680399