如果你不知道变量是啥类型的,可以像下面这样操作
|
|
简单原则:不要对str使用encode,不要对unicode使用decode
搞明白要处理的是str还是unicode, 使用对的处理方法(str.decode/unicode.encode)
不同编码转换,使用unicode作为中间编码
#s是code_A的str
|
|
http://wklken.me/posts/2013/08/31/python-extra-coding-intro.html
如果你不知道变量是啥类型的,可以像下面这样操作
|
|
简单原则:不要对str使用encode,不要对unicode使用decode
搞明白要处理的是str还是unicode, 使用对的处理方法(str.decode/unicode.encode)
不同编码转换,使用unicode作为中间编码
#s是code_A的str
|
|
http://wklken.me/posts/2013/08/31/python-extra-coding-intro.html