如何在Google Colab中使用动态参数调用Python脚本?
我正在尝试运行一个用于批次数据的Python脚本(在Google Colab中)。我尝试通过为每次运行提供不同的文件夹名称来动态保存结果。例如:
counter=counter+1
source='/myfolder/test_' + str(counter)
!python mycode.py --source source
它从字面上看对象“源”,因此它不会找到'/root/source/'之类的东西,但是如果我尝试使用:
!python mycode.py --source '/myfolder/test_' + str(counter)
它不会接受串联。有什么想法如何使该论点具有动态价值?
I'm trying to run a python script for batches of data (in Google Colab). I try to save the results dynamically by giving different folder names for each run. For example:
counter=counter+1
source='/myfolder/test_' + str(counter)
!python mycode.py --source source
It takes the object "source" literally so it wont find something like '/root/source/', but if I try using:
!python mycode.py --source '/myfolder/test_' + str(counter)
It won't accept the concatenation. Any ideas how to give that argument a dynamic value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我找到了答案。基本上,应该将其放入一个变量:
Okay, I found an answer. Basically, it should be put into a variable: