我有一个整数列表:
(83, 105, 101, 109, 101, 110, 115)
我相信 Siemens 的代码。
如何以 Python 方式将此列表转换为字符串?
我知道我可以使用 chr(x) 获取单个字符并将它们连接起来,但这似乎不是最好的方法。
请您参考如下方法:
使用 bytes (或 str )和 bytearray :
>>> bytes(bytearray((83, 105, 101, 109, 101, 110, 115)))
'Siemens'
在 Python 3.x 中:
>>> bytes((83, 105, 101, 109, 101, 110, 115)).decode()
'Siemens'
