6 Réponses
+ 6
Ayush Sinha
The raw string keeps the special characters like \n in their original form as two separate characters. Without r' prefix, the string converts it to an actual newline character which is a different and single, invisible control char.
Observe these two:
print(len('Hello\n')) # 6
print(len(r'Hello\n')) # 7
Also one remark, normally in the match function parameters, the pattern comes first and the text to match against, comes second.
+ 7
r defines a raw string. The '\n` stays text instead of being interpreted as a newline. Thus no match
+ 4
Obvioysly r' is converting to smth else again, pls read about r'
+ 4
Thomas Williams in the second if statement, try to remove r' inside if , it will print the same thing as in the first if statement
+ 4
Thomas Williams on 23rd line
+ 3
Zhenis Otarbay which one did you remove? Depending on that, the *comparison* could return True