Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个要转换为 unicode 字符的 Shift_JIS 字符代码(整数)列表。我想我需要一个chr()/unichr()适用于其他编码的函数版本。我已经尝试decode()与 结合使用hex(),但它只解码字符串本身,而不是十六进制值。
chr()/unichr()
decode()
hex()
示例输入和输出:
input = [91, 92, 48, 528] output = ["[", "¥", "0", "0"]
谁能帮我?提前致谢。
如果你从这样的事情开始:
bytearray = [65, 66, 67, 200, 156, 130]
然后这样做:
>>> ustring = reduce(operator.add, map(chr, bytearray)).decode('shift_jis') >>> ustring u'ABC\uff88\u6029'