Google colab 更改目录 [英] Google colab changing directory

查看:19
本文介绍了Google colab 更改目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在 Google colab 中更改我的目录.当我输入 cd 它会给出这样的输出/content"我试图使用导入操作系统os.chdir("驱动器")

I can't change my directory in Google colab. when I type cd it gives output like this '/content' I tried to change the directory using import os os.chdir("drive")

但它显示错误 No such file or directory: 'drive' .如何摆脱这种情况?

but it shows error No such file or directory: 'drive' . How to get rid of this?

推荐答案

如果要将目录从 google colab 更改为 google drive,请先连接到 google drive.

If you want to change directory from google colab into google drive, connect to google drive first.

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

它会询问可以获取的身份验证密钥登录您的 Google Drive 时

It will ask for authentication key that will be can be obtained when signing in to your google drive

切换到谷歌驱动器目录.

Change to the google drive directory.

%cd /content/drive/My Drive/

用于验证:!pwd

您当前的目录是 /content/drive/My Drive/

这篇关于Google colab 更改目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆