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.
23rd Jun 2019, 5:31 AM
Tibor Santa
Tibor Santa - avatar
+ 7
r defines a raw string. The '\n` stays text instead of being interpreted as a newline. Thus no match
23rd Jun 2019, 4:23 AM
Trigger
Trigger - avatar
+ 4
Obvioysly r' is converting to smth else again, pls read about r'
23rd Jun 2019, 4:22 AM
Zhenis Otarbay
Zhenis Otarbay - avatar
+ 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
23rd Jun 2019, 4:24 AM
Zhenis Otarbay
Zhenis Otarbay - avatar
+ 4
Thomas Williams on 23rd line
23rd Jun 2019, 4:37 AM
Zhenis Otarbay
Zhenis Otarbay - avatar
+ 3
Zhenis Otarbay which one did you remove? Depending on that, the *comparison* could return True
23rd Jun 2019, 4:27 AM
Trigger
Trigger - avatar