In Python, I have a string:
a = "\s"
In JavaScript, a would be the single letter "s", but in Python, a would be "\s".
How can I make Python behave the same way as JavaScript in this situation?
a = "<div class=\"haha\"><\/div>" , In this case , JavaScript get right HTML but python failed
Assuming that there are no encoding/decoding that is happening?
Is a == r"\s" ?
You could simply:
a.replace('\\','')
example:
>>> a = "<div class=\"haha\"><\/div>"
>>> a.replace('\\','')
'<div class="haha"></div>'
See:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With