python - How to read integers from byte file one time? -
i want read data .yuv file using python. these data uint8 integers. use such command:
fp = open(filename, 'rb') data = fp.read(100)
i 100 bytes data string. know can use ord()
transfer 1 byte str 1 integer 1 time. how can read or transfer 100 integers in array 1 time?
use struct.unpack
:
with open(filename, 'rb') fp: integers = struct.unpack('100b', fp.read(100))
Comments
Post a Comment