在Python的string前面加上‘r’, 是为了告诉编译器这个string是个raw string,不要转意backslash ‘’ 。
例:
加r:
print(r'hello,\n world')
输出结果:
hello,\n world
不加r:
print('hello,\n world')
输出结果:
hello,
world
如果字符串内部有很多换行,用\n写在一行里不好阅读,为了简化,Python允许用’’’…’’'的格式表示多行内容
例:
print(r'''hello,
world''')
输出结果:
hello,
world