ipython - 如何在 ipython(google colab)上使用变量运行 %cd?
问题描述
I want to access folders shared to me on drive, I have created a shortcut on my drive and I wanna access it from there. The problem I'm facing is I want to change directory using variable. But when I use this code:
for boxNo in range(109):
boxStr = "/gdrive/My Drive/Box Set {}".format(boxNo)
%cd -q setStr # The problem is here
url = !pwd
print("I have to use this url: " + url[0])
I get this error:
[Errno 0] No such file or directory: 'setStr'
SIDE-NOTE:
echo
or!echo
both don't work either as I writeecho url[0]
it displaysurl[0]
on the output. But inside parenthesis, as in print,print(url[0])
, it works. My guess is if I could change directory keeping the variable inside parenthesis it would work but I seem to find no way of doing so.
解决方案
推荐阅读
- java - 将对象从过滤器返回到资源
- javascript - 通过 Outlook 客户端使用 PHP 或 JavaScript 发送电子邮件
- docker - 在 Docker 中从源安装
- android - Android:基于 2 个微调器选择填充 ListView (JSON)
- c# - 在 Activity 的 OnCreate() 期间显示进度条?
- javascript - 时间序列图上的 Plotly.js 渐变颜色
- paypal - Paypal“创建支付资源”不起作用(401 Unauthorized)
- reactjs - 内在属性的默认值
- ios - 重新安装应用后未收到订阅收据
- ios - 如何在 WebKit 视图中获取单击元素的 ID?