[英]EOL while scanning string literal when trying to print a \ in python
I'm trying to print just a \\
using python and it seems like \\
is some kind of reserved character or something. 我正在尝试使用python打印仅一个
\\
,并且看来\\
是某种保留字符或其他内容。 The code print "\\"
returns SyntaxError: EOL while scanning string literal
. SyntaxError: EOL while scanning string literal
,代码print "\\"
返回SyntaxError: EOL while scanning string literal
。 Any suggestions? 有什么建议么?
The backslash is used in Python for escape sequences . 反斜杠在Python中用于转义序列 。 The proper way to do what you want is:
做您想要的事情的正确方法是:
print "\\" # You need to escape the \ character
您不能使用\\
字符结尾字符串,因为可能会要求它转义"
字符。您需要使用"\\\\"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.