0
hello everyone , I have observed something strange The lines print('$!/\\@$@!') and print('$!/\@$@!') are yielding same result . Can someone say why can this happen.
3 Antworten
+ 1
You just discovered that the backlash (\) character escapes some characters, that otherwise have a special meaning.
For more information read this please:
https://learnpythonthehardway.org/book/ex10.html
+ 1
Because backslash hints Python to expect a 'special escape sequence'. When one is not found (@ is not special), it dumps both \ and @.
Compare:
>>> print('\\\\')
\\
>>> print('\\\\ \@')
\\ \@
>>> print('\\\\ \n')
\\
<----- \n is "newline" (empty line here)
>>>
Learn Python The Hard Way (Escape Sequences section):
https://learnpythonthehardway.org/book/ex10.html
0
if that is the case, the output of the first statement must be $!/\@$@! and that of second must be $!/@$@!, right?