如何将我的转换bytearray('b\x9e\x18K\x9a')
为这样的东西--> \x9e\x18K\x9a
<---只是str,而不是数组!
>> uidar = bytearray()
>> uidar.append(tag.nti.nai.uid[0])
>> uidar.append(tag.nti.nai.uid[1])
>> uidar.append(tag.nti.nai.uid[2])
>> uidar.append(tag.nti.nai.uid[3])
>> uidar
bytearray('b\x9e\x18K\x9a')
我尝试通过解码我的字节数组
uid = uidar.decode('utf-8')
但它不能...
Traceback (most recent call last):
File "<pyshell#42>", line 1, in <module>
uid = uidar.decode("utf-8")
File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x9e in position 0: invalid start byte
请帮帮我 ...