python转义字符失效的原因是什么?
yang
2020-05-23 16:33:117801浏览 · 0收藏 · 0评论
python转义字符失效的原因:
1、转义字符前加了字母“r”
r 可使字符串内(除字符串最后一位是 \ 的情况)所有的转义字符 \ 都失效。
>>> print("hello world!") hello world! >>> print("hello\n world!") hello world! >>> print("hello"r"\n world!") hello\n world!
2、在转义字符前加“\”
更多Python知识请关注Python自学网。
关注公众号,随时随地在线学习