字符串前面加u:
代表为Unicode编码类型的字符串,如果字符串仅为英文,则一般不需要。
因为英文在几乎在各种编码中都能得到很好的解析。
但如果使用中文,一般都会使用Unicode编码,否则一旦出现转码,就会出现乱码
u'小姐姐,你好!'
字符串前面加r:
代表该字符串不进行转义
>>> s='You are the \"Apple\" of my eye.'
>>> print(s)
You are the "Apple" of my eye.
>>> s=r'You are the "Apple" of my eye.'
>>> print(s)
You are the "Apple" of my eye.
字符串前面加b:
代表为bytes类型数据
python3.x里默认的str是(py2.x里的)unicode, bytes是(py2.x)的str, b”“前缀代表的就是bytes
python2.x里, b前缀没什么具体意义, 只是为了兼容python3.x的这种写法