Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要编写一个程序来使用 512KB 块从磁盘中提取信息。磁盘映像文件为原始格式。
打开带有'rb'标志的文件以读取字节和read您的内容,大小参数为 512 * 2^10(或 512000,具体取决于您的大小是KB 还是 KiB。
'rb'
read
with open('filename', 'rb') as f: block = f.read(512 * 2**10) while block != "": # Do stuff with a block block = f.read(512 * 2**10)