python readinto直接读取到缓冲区

2019-09-30 18:33:14 浏览数 (1)

import os.path

def read_into_buffer(filename): buf = bytearray(os.path.getsize(filename)) with open(filename, 'rb') as f: f.readinto(buf) return buf

0 人点赞