本文最初发表于 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
时间: 2024-10-07 09:18:28