读二进制文件
size = 1280*720*3
file_name = r'D:\raw.dat'
with open(file_name, 'rb') as f:
data = f.read(size)
数字转byte
count_bytes = count.to_bytes(2, byteorder='little')
seq_bytes = seq.to_bytes(4, byteorder='big')
for i in range(count):
index_bytes = i.to_bytes(2, byteorder='little')
print(b'\x00\x00\x00\x8b', seq_bytes)
print(b'\x29\x00', index_bytes )
print(b'\x55\x00', total_bytes)
同时用C语言写的,c语言的数字转byte:
htons(total);
htons(index);
htonl(seq);