Reputation: 115
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
Upvotes: 3
Views: 638
Reputation: 24089
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:
Upvotes: 1