+ 1

Regular Expression

what is r when making a pattern like in r"spam"? like in the example: import re str = "My name is David. Hi David." pattern = r"David" newstr = re.sub(pattern, "Amy", str) print(newstr) it works the same if we set the value of pattern to "David" instead of r"David"

5th Oct 2020, 9:24 AM
Yusuf Bakkour Mustafa
Yusuf Bakkour Mustafa - avatar
2 ответов
+ 4
string literal a = "hello\nworld" b = r"hello\nworld" try print u will see the difference
5th Oct 2020, 9:27 AM
durian
durian - avatar
0
thanks
5th Oct 2020, 10:58 AM
Yusuf Bakkour Mustafa
Yusuf Bakkour Mustafa - avatar