我正在使用shutil
和ISO9660并尝试将提取的ISO文件复制到新目录中。但是,当我尝试复制信息时,我收到错误告诉我:
Traceback (most recent call last):
File "uboot.py", line 7, in <module>
unzip_iso("dsl-4.11.rc1.iso")
File "/home/baal/bin/python/uboot/lib/settings.py", line 138, in unzip_iso
shutil.copyfile(iso_item, create_filename(filepath))
File "/usr/lib/python2.7/shutil.py", line 82, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: '/BOOT'
我使用的代码:
def unzip_iso(filepath, verbose=False):
iso_file = ISO9660(filepath)
def create_dirname(path):
data = path.split("/")[-1]
items = data.split(".")
return items[0]
for iso_item in iso_file.tree():
if iso_item == "/":
pass
else:
shutil.copyfile(iso_item, create_dirname(filepath))
如何将ISO文件成功复制到新目录?