I need to doubly escape all escaped characters in a string in python. So, for example, any instances of '\n'
need to be replaced by '\\n'
I can easily do this one character at a time with
s = s.replace('\n', '\\n')
s = s.replace('\r', '\\r')
# etc...
But I'm wondering if there's a one-off way to handle all of them.