bytearray, type and format confusion
soren last edited by soren
Hello, I could really use a hint here as to understand the type bytearray which I'm using for sending to a java socket on an rpi.
In REPL console I typed this:
data = bytearray() print(data) **bytearray(b'')** data.append(40000) print(data) **bytearray(b'@')** print(data, encoding='utf8') **bytearray(b'@')**
What format is this? How come that the int 40000 is shown as '@' ?? It's not hexadecimal and it's not a byte (0-255), but obviously there's something I don't get..
jcaron last edited by jcaron
@soren Add ``` alone on the lines before and after your code, or prefix them all with 4 spaces to have them formatted as code.
40000 % 256(or
40000 & 255, i.e. keeping the 8 least significant bits) = 64, which is the code point for