且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用python从zip文件中删除路径

更新时间:2023-11-29 19:20:46

如何将文件读取为二进制文件并将其转储?需要处理已有文件的情况.

How about reading file as binary and dump it? Need to deal cases where there is pre-existing file.

for name in zfile.namelist():

    fname = os.path.join(zipdir, os.path.basename(name))
    fout = open(fname, 'wb')
    fout.write(zfile.read(name))