I'm trying to figure out why Python 3.8.2 considers this is true
"HELLO\\WORLD" == """HELLO\WORLD"""
But this is false
"HELLO\\2" == """HELLO\2"""
Why is \2
not interpreted the same in both sides of the string ?
CodePudding user response:
\2
is an octal escape (\x02
) while \\2
is an escaped \
, followed by the numeral 2
. The W
doesn't have a valid escape so "\W"
== "\\W"