Qual è la differenza tra bytearray
e, ad esempio, uno list
o tuple
?Differenza tra bytearray e lista
Come suggerisce il nome, bytearray
deve essere uno array
che trasporta oggetti byte
.
In Python, sembra che bytes
e str
vengono trattati allo stesso modo
>>> bytes
<type 'str'>
Quindi, qual è la differenza?
Inoltre, se si stampa un bytearray
, il risultato è piuttosto strano
>>> v = bytearray([200, 201])
>>> print v
ÈÉ
Sembra che trasforma il numero intero in chr(integer)
, è giusto? A cosa serve poi un bytearray
?
Contrassegna la tua versione python, per favore, perché 'str' differisce pesantemente tra python 2 e python 3. – dhke
Ben notato! È 'python- 2.7' – RafaelC
Vedi qui https://stackoverflow.com/questions/9099145/where-are-python-bytearrays-used – dhke