zipfile extractall引发“ BadZipFile:文件的错误CRC-32”错误

时间:2019-05-19 04:29:05

标签: python zip

这是我要打开的文件

https://drive.google.com/file/d/1K2kDBTNXS2ikx9xKmi2Fy0Wsc5u_Lls0/view

在这里描述

https://github.com/armancohan/long-summarization

将文件添加到Google驱动器后,这就是我试图用来打开它的代码。

from google.colab import drive
drive.mount('/content/gdrive')
import zipfile

zip_ref = zipfile.ZipFile('/content/gdrive/My Drive/arxiv-release.zip', 'r')
zip_ref.extractall('arxiv-release')
zip_ref.close()

这是引发的错误

---------------------------------------------------------------------------
BadZipFile                                Traceback (most recent call last)
<ipython-input-9-9965160388a1> in <module>()
      1 
----> 2 zip_ref.extractall('arxiv-release')
      3 zip_ref.close()

5 frames
/usr/lib/python3.6/zipfile.py in extractall(self, path, members, pwd)
   1522 
   1523         for zipinfo in members:
-> 1524             self._extract_member(zipinfo, path, pwd)
   1525 
   1526     @classmethod

/usr/lib/python3.6/zipfile.py in _extract_member(self, member, targetpath, pwd)
   1577         with self.open(member, pwd=pwd) as source, \
   1578              open(targetpath, "wb") as target:
-> 1579             shutil.copyfileobj(source, target)
   1580 
   1581         return targetpath

/usr/lib/python3.6/shutil.py in copyfileobj(fsrc, fdst, length)
     77     """copy data from file-like object fsrc to file-like object fdst"""
     78     while 1:
---> 79         buf = fsrc.read(length)
     80         if not buf:
     81             break

/usr/lib/python3.6/zipfile.py in read(self, n)
    870         self._offset = 0
    871         while n > 0 and not self._eof:
--> 872             data = self._read1(n)
    873             if n < len(data):
    874                 self._readbuffer = data

/usr/lib/python3.6/zipfile.py in _read1(self, n)
    960         if self._left <= 0:
    961             self._eof = True
--> 962         self._update_crc(data)
    963         return data
    964 

/usr/lib/python3.6/zipfile.py in _update_crc(self, newdata)
    888         # Check the CRC if we're at the end of the file
    889         if self._eof and self._running_crc != self._expected_crc:
--> 890             raise BadZipFile("Bad CRC-32 for file %r" % self.name)
    891 
    892     def read1(self, n):

BadZipFile: Bad CRC-32 for file 'arxiv-release/train.txt'

0 个答案:

没有答案