Python 代码中如何读取字节中的位
```
def get_bit(b):
byte = ord(b)
print("byte:{}".format(byte))
byte = bin(byte)[2:].rjust(8, '0')
print("byte:{}".format(byte))
for bit in byte:
print(bit)
```
#字符使用:
get_bit('a'.encode())
#输出:
byte:97
byte:01100001
0
1
1
0
0
0
0
1
#数值使用:
num = 2
get_bit(num.to_bytes(1, 'big'))
#输出:
byte:2
byte:00000010
0
0
0
0
0
0
1
0
我的笔记