import zipfile
#从压缩包里解压文件
with zipfile.ZipFile("作业.zip","r") as zipobj:
zipobj.extract("rm.txt")
上面就是需要解压的文件,输出之后直接报错了
Traceback (most recent call last):
File "E:/pycharm/python项目/one.py", line 130, in <module>
zipobj.extract("rm.txt")
File "C:\Users\wangyuhui\AppData\Local\Programs\Python\Python38\lib\zipfile.py", line 1630, in extract
return self._extract_member(member, path, pwd)
File "C:\Users\wangyuhui\AppData\Local\Programs\Python\Python38\lib\zipfile.py", line 1669, in _extract_member
member = self.getinfo(member)
File "C:\Users\wangyuhui\AppData\Local\Programs\Python\Python38\lib\zipfile.py", line 1441, in getinfo
raise KeyError(
KeyError: "There is no item named 'rm.txt' in the archive"