Cómo convertir mi bytearray ('b \ x9e \ x18K \ x9a') a algo como esto -> '\ x9e \ x18K \ x9a' <--- simplemente str, no array
Como convertir mibytearray('b\x9e\x18K\x9a')
a algo como esto ->\x9e\x18K\x9a
<--- sólo str, no array!
<code>>> 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') </code>
Intento decodificar mi bytearray por
<code>uid = uidar.decode('utf-8') </code>
pero no puede ...
<code>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 </code>
Ayudame por favor ...