本文最初发表于 http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=4143291&page=1#pid24220123
Hello
World!
In [3]: s.encode(‘string_escape‘)
Out[3]: ‘Hello\\nWorld!‘
In [4]: Out[3].decode(‘string_escape‘)
Out[4]: ‘Hello\nWorld!‘
Not *quite* what you asked for, but it ought to be close enough.
python中处理读入文件中的转义字符,布布扣,bubuko.com
原文地址:http://blog.csdn.net/linustd/article/details/34414147