0

我有一个要转换为 unicode 字符的 Shift_JIS 字符代码(整数)列表。我想我需要一个chr()/unichr()适用于其他编码的函数版本。我已经尝试decode()与 结合使用hex(),但它只解码字符串本身,而不是十六进制值。

示例输入和输出:

input = [91, 92, 48, 528]

output = ["[", "¥", "0", "0"]

谁能帮我?提前致谢。

4

1 回答 1

0

如果你从这样的事情开始:

bytearray = [65, 66, 67, 200, 156, 130]

然后这样做:

>>> ustring = reduce(operator.add, map(chr, bytearray)).decode('shift_jis')
>>> ustring
u'ABC\uff88\u6029'
于 2011-08-18T20:08:41.477 回答