字符串替换问题 test.replace('\','\\') 显示红线 我想应该是字符转义的问题 有什么方法可以执行成功呢
字符串替换问题 test.replace('\','\\') 显示红线 我想应该是字符转义的问题 有什么方法可以执行成功呢
[解决办法]
Escape Characters:
Following table is a list of escape or non-printable characters that can be represented with backslash notation.
NOTE: In a doublequoted string, an escape character is interpreted; in a singlequoted string, an escape character is preserved.
Backslash
notationHexadecimal
characterDescription
\a0x07Bell or alert
\b0x08Backspace
\cx Control-x
\C-x Control-x
\e0x1bEscape
\f0x0cFormfeed
\M-\C-x Meta-Control-x
\n0x0aNewline
\nnn Octal notation, where n is in the range 0.7
\r0x0dCarriage return
\s0x20Space
\t0x09Tab
\v0x0bVertical tab
\x Character x
\xnn Hexadecimal notation, where n is in the range 0.9, a.f, or A.F
http://www.tutorialspoint.com/python/python_strings.htm