I got two objects, a
and b
, each containing a single byte in a bytes object.
I am trying to do a bitwise operation on this to get the two most significant bits (big-endian, so to the left).
a = sock.recv(1)
b = b'xc0'
c = a & b
However, it angrily spits a TypeError
in my face.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for &: 'bytes' and 'bytes'
Is there any way I can perform an AND operation on the two bytes without having to think of the host system's endianness?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…