I need to replace some characters as follows: &\&, #\#, …

I coded as follows, but I guess there should be some better way. Any hints?

strs = strs.replace('&', '\&')
strs = strs.replace('#', '\#')
...

15 Answers
15

Leave a Reply

Your email address will not be published. Required fields are marked *