我是google colab的新手,我正在确定google colab是否能够直接访问计算机cdrive上的文件。
import os
path = 'C:\\Users\\guest\\Desktop\\'
for file in os.listdir(path):
print(file)
出现的错误消息是[Errno 2]没有这样的文件或目录:'C:\ Users \ zhuan.lim \ Desktop \ script tools \ Python Scripts'
我在线搜索,并且有些示例说首先使用以下文件上传文件:
from google.colab import files
uploaded = files.upload()
但是,google colab是否有另一种方法可以直接从驱动器中读取?
提前感谢。
不直接,不。但是您可以将文件拖放到Google Drive中,然后通过在单元格中插入以下行并执行它来将其挂载到您的Google Colab会话中:
from google.colab import drive
drive.mount('/content/gdrive')
它会提示您进入一个URL进行身份验证。单击URL并允许Google Colab访问您的Google云端硬盘文件后,即可访问您的Google云端硬盘文件。这里更详细的解释:Import data into Google Colaboratory
直接回答您的问题:据我所知,没有colab.upload_from_pc
。