LEADING_BIT_MASK = 128
VALUE_MASK = 127
bytes = [170, 85, 0, 128]
for byte in bytes:
    value = byte & VALUE_MASK
has_leading_bit = byte & LEADING_BIT_MASK
if value == 0:
    print('EOL')
elif has_leading_bit:
    print('leading one', value)
elif not has_leading_bit:
    pass
Python: извлечение битов из байта