首页 > 解决方案 > 为什么python gzip会引发关闭文件错误?

问题描述

我有一个要解压缩的文件。它存储在一个变量中。

代码:

print(bytes_db)

with gzip.open(bytes_db, 'rb') as db:
    print(db)
    db.read()

结果是关闭文件上的错误。完整输出:

<gzip on 0x7f2737f23250>
<gzip gzip on 0x7f2737f23250 0x7f273c5e3430>
ValueError: I/O operation on closed file

标签: pythongzip

解决方案


推荐阅读