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

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

问题描述

我无法在Google colab中更改目录。当我输入cd时,它会给出类似 / content的输出,我尝试使用
import os
os.chdir( drive)更改目录

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此类文件或目录:'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云端硬盘时,它会要求获得可以获取的认证密钥

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

转到Google驱动器目录。

Change to the google drive directory.

%cd /content/drive/My\ Drive/

用于验证:
!pwd

For verifying: !pwd

您当前的目录为 / content / drive /我的云端硬盘/

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

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