我不知道如何将Python的bitarray转换为字符串,如果它包含非ASCII字节。例如:
>>> string='\x9f'
>>> array=bytearray(string)
>>> array
bytearray(b'\x9f')
>>> array.decode()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0x9f in position 0: ordinal not in range(128)
在我的例子中,我只想从bytearray中以某种方式获取字符串'\x9f'。这是否可能?