python读取字节中的位

s = b'\x0b'
byte = ord(b)
logprint("byte:{}".format(byte))
byte = bin(byte)[2:].rjust(8, '0')
logprint("byte:{}".format(byte))
for bit in byte:
    logprint(bit)

输入

byte:11
byte:00001011
0
0
0
0
1
0
1
1

 

posted @ 2021-08-05 22:41  乱炖er  阅读(458)  评论(0编辑  收藏  举报