arcpy。python创建zip文件
import os
import zipfile
#create the zip file
zfile = zipfile.ZipFile(“shapefiles2.zip”, “w”, zipfile.ZIP_STORED)
files = os.listdir(“c:/ArcpyBook/data”)
for f in files:
if f.endswith(“shp”) or f.endswith(“dbf”) or f.endswith(“.shx”):
zfile.write(“C:/ArcpyBook/data/” + f)
#list files in the archive
for f in zfile.namelist():
print(“Added %s” % f)
zfile.close()
import os
import zipfile
#create the zip file
zfile = zipfile.ZipFile(“shapefiles2.zip”, “w”, zipfile.ZIP_DEFLATED)
files = os.listdir(“c:/ArcpyBook/data”)
for f in files:
if f.endswith(“shp”) or f.endswith(“dbf”) or f.endswith(“.shx”):
zfile.write(“C:/ArcpyBook/data/” + f)
#list files in the archive
for f in zfile.namelist():
print(“Added %s” % f)
zfile.close()
转载自:https://blog.csdn.net/A873054267/article/details/86007551