参考: python - Google Colab: how to read data from my google drive? - Stack Overflow
其他答案我都试过, 效果不行, 但是以下work for me:
What I have done is first:
from google.colab import drive
drive.mount('/content/drive/')
Then
%cd /content/drive/My Drive/Colab Notebooks/
After I can for example read csv files with
df = pd.read_csv("data_example.csv")
If you have different locations for the files just add the correct path after My Drive
这篇博客介绍了如何在GoogleColab中成功读取GoogleDrive上的数据。首先,通过`from google.colab import drive`导入drive模块并挂载GoogleDrive。然后,使用`%cd`命令切换到数据所在的目录,例如`/content/drive/MyDrive/ColabNotebooks/`。最后,可以使用pandas的`read_csv()`函数读取CSV文件。这种方法对于在Colab中访问个人GoogleDrive文件非常有效。
6774

被折叠的 条评论
为什么被折叠?



