<分区>
我可以毫无问题地使用其他转义字符,但我的原子文本编辑器和 python 本身并不将其视为转义字符,而是将其视为普通字符。
print '\s', test_line
只是写
\stesting_bot1
我怎样才能使编辑器和 python 将其视为转义字符和空格?
<分区>
我可以毫无问题地使用其他转义字符,但我的原子文本编辑器和 python 本身并不将其视为转义字符,而是将其视为普通字符。
print '\s', test_line
只是写
\stesting_bot1
我怎样才能使编辑器和 python 将其视为转义字符和空格?
最佳答案
\s
不是 Python 中的转义序列。 \t
、\n
、\r
等(参见 the Python lexical analysis docs)但非特殊字符不会被解释为任何特殊字符,因此你的 \s
字面上出现。
但是,\s
表示 regular expression syntax 中的空格当然……
关于python - 不能使用\s 作为转义字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39069109/