目录
1.转义字符 \
Python 字符串是以单引号或双引号括起来的任意文本,如果字符串中包含引号怎么办?
# 对 ' " 转义
>>> print('I\'m ok.')
I'm ok.
# 对 \自身转义
>>> file = 'C:\\Users\\86188\\Desktop'
>>> file
'C:\\Users\\86188\\Desktop'
换行符 \n 制表符 \t
# 换行
>>> print('What language do you program in?\nI\'m is Python')
What language do you program in?
I'm is Python
# 制表符:垂直方向上对齐文本
>>> print('\tThe printed results are aligned')
The printed results are aligned
2.字符串前缀 r,b,u,f
#1 字符串前缀 r
# 字符串中 \较多,可用字符串 r前缀
>>> file = r'C:\Users\86188\Desktop'