Colab挂载Google Drive

网上的一些挂载教程都比较老了, Colab官方给出了简洁的新版本介绍. 下面总结一下挂载步骤.

下面的样例展示了一种通过输入授权码将Google Drive挂载至Colab虚拟机的方法.

from google.colab import drive
drive.mount('/drive')

运行上述代码后输出:

Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=email%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdocs.test%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.photos.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fpeopleapi.readonly&response_type=code
Enter your authorization code:
··········
Mounted at /drive

Colab挂载Google Drive_第1张图片
按下回车键即可完成挂载, 之后就可以看到文件夹了:
Colab挂载Google Drive_第2张图片

你可能感兴趣的:(机器学习)