|
1
import re
re.escape('\\r\\n') |
|
2
```
$ 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 也很好用 |
|
banbanchsDec 11, 2014
4
s.encode("unicode_escape") ?
|
|
staticorDec 11, 2014
5
repr(s).replace('\\', '\\\\')
|
|
jiankangxinDec 11, 2014
6
@iptux 之前一直在用 replace 原来。。。
|
|
kungfuchickenDec 11, 2014
7
"\\".join(r'\r\n'.split("\\"))
|
|
lygmqklDec 11, 2014
8
我都是在 js层做这个 转换得,感觉存入数据库得时候改变并不是很好。
|