- 自己每次在kaggle上运行得到结果,每次得到几百张或者是几千张图片
- 每次下载,我手都点废了
- 打包下来之后,可以一次下载
import os, zipfile
#打包目录为zip文件(未压缩)
def make_zip(source_dir, output_filename):
zipf = zipfile.ZipFile(output_filename, 'w')
pre_len = len(os.path.dirname(source_dir))
for parent, dirnames, filenames in os.walk(source_dir):
for filename in filenames:
pathfile = os.path.join(parent, filename)
arcname = pathfile[pre_len:].strip(os.path.sep) #相对路径
zipf.write(pathfile, arcname)
zipf.close()
make_zip("./processed/sentences","sentences.zip")