![图片[1]-python转义字符失效的原因是什么?-uusu优素-乐高,模型,3d打印,编程](http://uusucn.zbbe.cn/wp-content/uploads/2024/01/5ecb6387dc971860.jpg)
python转义字符失效的原因:
1、转义字符前加了字母“r”
r 可使字符串内(除字符串最后一位是 \ 的情况)所有的转义字符 \ 都失效。
>>>print("helloworld!")
helloworld!
>>>print("hello\nworld!")
hello
world!
>>>print("hello"r"\nworld!")
hello\nworld!
2、在转义字符前加“\”

© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END

![图片[1]-python转义字符失效的原因是什么?-uusu优素-乐高,模型,3d打印,编程](http://uusucn.zbbe.cn/wp-content/uploads/2024/01/5ecb6387dc971860.jpg)
python转义字符失效的原因:
1、转义字符前加了字母“r”
r 可使字符串内(除字符串最后一位是 \ 的情况)所有的转义字符 \ 都失效。
>>>print("helloworld!")
helloworld!
>>>print("hello\nworld!")
hello
world!
>>>print("hello"r"\nworld!")
hello\nworld!
2、在转义字符前加“\”

暂无评论内容