
#按位打印出来
f = open("E:\data211008151402.dat", 'rb')
# read one byte
byte = f.read(1)
# convert the byte to an integer representation
byte = ord(byte)
# now convert to string of 1s and 0s
s = hex(byte).zfill(2).encode()
byte = bin(byte)[2:].rjust(8, '0')
print(s)
# now byte contains a string with 0s and 1s
for bit in byte:
print(bit)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)