Python 从Colaboratory访问Google Drive中的文件夹

Python 从Colaboratory访问Google Drive中的文件夹,python,directory,google-drive-api,google-colaboratory,Python,Directory,Google Drive Api,Google Colaboratory,我希望能够从Colaboratory读取和写入Google Drive中的文件夹中的文件,但无法确定如何访问特定文件夹 我成功地安装了我的驱动器,然后做了一个文件列表。清单显示了我感兴趣的目录(为简洁起见进行了编辑),因此我试图更改到该目录,但出现了一个错误 from google.colab import drive drive.mount('/content/drive') Drive already mounted at /content/drive; to attem

我希望能够从Colaboratory读取和写入Google Drive中的文件夹中的文件,但无法确定如何访问特定文件夹

我成功地安装了我的驱动器,然后做了一个文件列表。清单显示了我感兴趣的目录(为简洁起见进行了编辑),因此我试图更改到该目录,但出现了一个错误

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

    Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount("/content/drive", force_remount=True)

import os
os.listdir()
输出(已编辑)

['99温度', “02工作”, ‘01家’, “住宅建筑关键资料表.pdf”, “主页内容关键事实表.pdf”, ....., “旅行保险安联保险证书.pdf”, “数据”]

os.chdir(“驱动器/数据”)
os.listdir()
*FileNotFoundError回溯(最近一次调用上次)
在()
---->1 os.chdir(“驱动器/数据”)
2 os.listdir()
FileNotFoundError:[Errno 2]没有这样的文件或目录:“驱动器/数据”*

如果要移动到编辑输出的最后一个元素中列出的“数据”目录,请尝试此操作。看起来您已经在
/content/drive
中了

os.chdir(“数据”)
os.listdir()
您可以通过
pwd
命令确认当前工作目录

!pwd
!pwd


如果要移动到已编辑输出的最后一个元素中列出的“数据”目录,请尝试此操作。看起来您已经在
/content/drive
中了

os.chdir(“数据”)
os.listdir()
您可以通过
pwd
命令确认当前工作目录

!pwd
!pwd


我的回答基于这样的假设:Google Drive中的“数据”文件夹保存在我的驱动器文件夹下(默认情况下,Google Drive是正常的)


我的回答基于这样的假设:Google Drive中的“数据”文件夹保存在我的驱动器文件夹下(默认情况下,Google Drive是正常的)