如何在kaggle上下载输出文件
输出的文件没有下载的选项,怎么办
那就把output打包成压缩包,就会出现下载选项
import os
import zipfile
import datetime
def file2zip(packagePath, zipPath):
'''
:param packagePath: 文件夹路径
:param zipPath: 压缩包路径
:return:
'''
zip = zipfile.ZipFile(zipPath, 'w', zipfile.ZIP_DEFLATED)
for path, dirNames, fileNames in os.walk(packagePath):
fpath = path.replace(packagePath, '')
for name in fileNames:
fullName = os.path.join(path, name)
name = fpath + '\\' + name
zip.write(fullName, name)
zip.close()
if __name__ == "__main__":
# 文件夹路径
packagePath = '/kaggle/working/'
zipPath = '/kaggle/working/output.zip'
if os.path.exists(zipPath):
os.remove(zipPath)
file2zip(packagePath, zipPath)
print("打包完成")
print(datetime.datetime.utcnow())