09
2020
11

Colab links to Gdrive

!apt-get install -y -qq software-properties-common python-software-properties module-init-tools

!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null

!apt-get update -qq 2>&1 > /dev/null

!apt-get -y install -qq google-drive-ocamlfuse fuse


首先install以上 modules入Colab 既linux server度看,然後可以開始你既代碼人生


from google.colab import auth

auth.authenticate_user()

from oauth2client.client import GoogleCredentials

creds = GoogleCredentials.get_application_default()

import getpass

!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL

vcode = getpass.getpass()

!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}


!mkdir -p drive

!google-drive-ocamlfuse drive







import os

from google.colab import drive

drive.mount('/content/drive')


path = "/content/drive/My Drive"


os.chdir(path)

os.listdir(path)



Simple way to upload a file


from google.colab import files

uploaded = files.upload()

« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。