This code works perfectly:
b'\x4a' + b'\x20'
b'J '
But this doesn't:
sum([b'\x4a', b'\x20'])
TypeError: unsupported operand type(s) for +: 'int' and 'bytes'
Why? How to concatenate many bytes
elements?
You can use join
instead:
b''.join([b'\x4a', b'\x20'])
Output:
b'J '