Is there a byte type in Python3? I only know there is a bytearray.
What I want is that, there is a byte 0x01
, then do the Complement Operator ~
the result will be 0xFE
, however when I do the following steps, the result is -2
and -2
can't be added to the bytearray.
>>> data=bytearray([0x01])
>>> data
bytearray(b'\x01')
>>> ~data[0]
-2
>>> data[0]=~data[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: byte must be in range(0, 256)