python學習2(轉義符的學習)
阿新 • • 發佈:2021-02-10
轉義符
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')
效果展示: