2014-06-18 38 views

回答

1

你必须转义反斜线:

\\ 

Python Docs

The backslash (\) character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character.

此外,作为@ Torxed在他的回答中提到,可以使用前缀rR

String literals may optionally be prefixed with a letter 'r' or 'R' ; such strings are called raw strings and use different rules for interpreting backslash escape sequences.

r"Some string with \ backslash" 
1

或使用:

print(r'This is \backslash') 

但建议使用this \\backslash逃逸。