colab 更优雅的上传与下载文件

上传文件

from google.colab import files
import shutil
import os
basepath = os.getcwd()
uploaded = files.upload() # 上传文件
upload_path = os.path.join(basepath, "test_images", "upload")
for filename in uploaded.keys():
    #将上传的文件移动到指定的位置上 
    shutil.move(os.path.join(basepath, filename), os.path.join(upload_path, filename)) 

下载文件

from google.colab import files
files.download("./result.zip")

你可能感兴趣的:(colab 更优雅的上传与下载文件)