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 下载google drive 文件

colab 使用小技巧_第1张图片

!gdown --id '177bC-AresW8tMq54_q84K6Eav_hGxUZE'
文件的id 可以在分享链接/d/后面的一串字符中找到 比如如下链接:
https://drive.google.com/file/d/177bC-AresW8tMq54_q84K6Eav_hGxUZE/view?usp=sharing
id 就为:177bC-AresW8tMq54_q84K6Eav_hGxUZE

你可能感兴趣的:(python)