在Google colab中更改目录(突破了python解释器) [英] Changing directory in Google colab (breaking out of the python interpreter)

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

问题描述

所以我正在尝试使用Google collab将git clone和cd混入该目录-但是我无法cd入它.我在做什么错了?

So I'm trying to git clone and cd into that directory using Google collab - but I cant cd into it. What am I doing wrong?

!rm -rf开关频率分析&& git clone https://github.com/ACECentre/SwitchFrequencyAnalysis.git

!cd SwitchFrequencyAnalysis

!cd SwitchFrequencyAnalysis

!ls datalab/SwitchFrequencyAnalysis/

!ls datalab/ SwitchFrequencyAnalysis/

您希望它输出SwitchFrequencyAnalysis的目录内容-而是输出其根目录.我感觉自己缺少明显的东西-与python解释器有关吗? (文档在哪里?)

You would expect it to output the directory contents of SwitchFrequencyAnalysis - but instead its the root. I'm feeling I'm missing something obvious - Is it something to do with being within the python interpreter? (where is the documentation??)

此处为演示.

推荐答案

使用

%cd SwitchFrequencyAnalysis

%cd SwitchFrequencyAnalysis

更改笔记本环境的当前工作目录(而不仅仅是运行!命令的子外壳).

to change the current working directory for the notebook environment (and not just the subshell that runs your ! command).

您可以像这样通过pwd命令确认它是否可以工作:

you can confirm it worked with the pwd command like this:

!pwd

!pwd

有关jupyter/ipython magics的更多信息: http://ipython.readthedocs.io/en/stable/interactive /magics.html#magic-cd

further information about jupyter / ipython magics: http://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-cd

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

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