Hello, everyone
import re
b = 'Yay\\'
a = re.compile('\\\\')
print(re.sub(a, '@', b))
You can do it like this, but this... I searched and found that the string parser removes two backslashes. So I added one to recognize it as just a slash, plus two to be removed from the parser, so it became four ;;
import re
b = 'Yay\\'
a = re.compile(r'\\')
print(re.sub(a, '@', b))
Or, if you put an "r" in front of the original string, you can get what you want because the parser doesn't touch it Yay!
© 2024 OneMinuteCode. All rights reserved.