Colab使用

导入drive资源

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

也可以在文件夹附近点按钮导入

导入后,手动切换到工作目录,ipynb代码里一些from等就可以用了。

! % 区别

from here

The difference is this:

  • When you run a command with !, it directly executes a bash command in a subshell.

  • When you run a command with %, it executes one of the magic commands defined in IPython.

Some of the magic commands defined by IPython deliberately mirror bash commands, but they differ in the implementation details.

For example, running the !cd bash command does not persistently change your directory, because it runs in a temporary subshell. However, running the %cd magic command will persistently change your directory:

!pwd
# /content

!cd sample_data/
!pwd
# /content

%cd sample_data/
!pwd
# /content/sample_data
posted @   jaskso  阅读(12)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示