这是一个创建于 2984 天前的主题,其中的信息可能已经有所发展或是发生改变。
比如一个字符串:
a = '哈哈'
解码后 a.decode('utf-8')输出的是:
u'\u54c8\u54c8'
但是现在接收到的字符串是 '\u54c8\u54c8' 这种类型的,看起来是 unicode 的字节,但是是 str 类型, 该怎样处理呢
2 条回复 • 2016-12-12 17:10:17 +08:00
![Sylv](https://cdn.v2ex.com/avatar/f54c/804b/51499_normal.png?m=1419125175) |
|
1
Sylv 2016-12-12 16:21:45 +08:00 via iPhone 4
'\u54c8\u54c8'.decode('unicode-escape')
|
![wdg8106](https://cdn.v2ex.com/gravatar/54bae6ed5f8d5abfcedcf71fc8e6aad7?s=48&d=retro) |
|
2
wdg8106 2016-12-12 17:10:17 +08:00
|