1
tomriddle Dec 11, 2014 import re
re.escape('\\r\\n') |
2
iptux Dec 11, 2014 ```
$ python Python 2.7.3 (default, Feb 27 2014, 19:58:35) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> '\r\n'.encode('string_escape') '\\r\\n' >>> ``` hex 的 encoding 也很好用 |
4
banbanchs Dec 11, 2014
s.encode("unicode_escape") ?
|
5
staticor Dec 11, 2014
repr(s).replace('\\', '\\\\')
|
6
jiankangxin Dec 11, 2014
@iptux 之前一直在用 replace 原来。。。
|
7
kungfuchicken Dec 11, 2014
"\\".join(r'\r\n'.split("\\"))
|
8
lygmqkl Dec 11, 2014
我都是在 js层做这个 转换得,感觉存入数据库得时候改变并不是很好。
|