简体   繁体   English

Python:打开文件进行读取时,gzip会写入磁盘吗?

[英]Python: does gzip write to disk when opening a file for read?

I am writing a program that reads .gz archived log files from an SD card. 我正在编写一个程序,可以从SD卡读取.gz存档日志文件。 If I open a .gz archive for reading using the gzip library, will it write a temporary copy to the SD card (I don't want it to), or does it decompress the file in RAM? 如果我打开一个.gz归档文件以使用gzip库进行读取,它会向SD卡写入一个临时副本(我不希望这样做),还是将其解压缩到RAM中的文件?

You didn't show how exactly you're doing it, but if you are using gzip.open() and read() , then there are no temporary files. 您没有显示操作的精确程度,但是如果使用的是gzip.open()read() ,则没有临时文件。 It is decompressed in memory. 它在内存中解压缩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM