문제

I'm trying to print just a \ using python and it seems like \ is some kind of reserved character or something. The code print "\" returns SyntaxError: EOL while scanning string literal. Any suggestions?

도움이 되었습니까?

해결책

The backslash is used in Python for escape sequences. The proper way to do what you want is:

print "\\" # You need to escape the \ character

다른 팁

You can't end a string with a \ character since you could be asking it to escape the " character. You need to use "\\"

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top