使用 gzip.open 替换/修改 gz 文件的尾部
我有一个很大的 gz 文件,是否可以在不触及文件其余部分的情况下替换尾部?我尝试了 gzip.open( filePath, mode = 'r+' ) 但写入方法被阻止....说它是只读对象...知道吗?
我现在正在做的是... gzip.open as r ,一旦获得尾部开始的偏移量,我将其关闭并使用 gzip.open as a 重新打开它并寻求(偏移量)...这可能不是最好的主意,
谢谢
约翰
I have a gz file that with a huge size, is it possible to replace the tail without touching the rest of the file? I tried gzip.open( filePath, mode = 'r+' ) but the write method was blocked .... saying it is a read-only object ... any idea?
what I am doing now is... gzip.open as r and once I get the offset of the start of the tail, I close it and re-open it with gzip.open as a and seek (offset)... which is not likely the best idea
thanks
John
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可能 - 如果不先解压缩压缩文件,则无法替换其部分内容。至少不是常见的压缩算法。
Not possible - you can not replace parts of a compressed file without decompressing it first. At least not with the common compression algorithms.