【发布时间】:2020-01-01 08:53:47
【问题描述】:
我希望能够从 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 家', '家庭建筑-关键事实-Sheet.pdf', 'Home-Contents-Key-Facts-Sheet.pdf', ……, 'Travel Insurance Allianz Certificate of Insurance.pdf', '数据']
os.chdir("drive/Data")
os.listdir()
*FileNotFoundError Traceback (most recent call last)
<ipython-input-25-853a98f4629a> in <module>()
----> 1 os.chdir("drive/Data")
2 os.listdir()
FileNotFoundError: [Errno 2] No such file or directory: 'drive/Data'*
【问题讨论】:
标签: python directory google-drive-api google-colaboratory