[英]Is there a way to pass a command line argument when running a cell in Jupyter Notebook?
I would like to pass a command line argument while running a cell in a Jupyter Notebook? 我想在Jupyter Notebook中运行单元时传递命令行参数吗?
Is this functionality supported? 是否支持此功能? If so how can I do it? 如果可以,我该怎么办?
Thanks! 谢谢!
For simple cases, just as reading in some numbers from the command line, input
can be used. 对于简单的情况,就像从命令行读取一些数字一样,也可以使用input
。
In the following example, a list of lists for user inputs is generated: 在以下示例中,生成了用于用户输入的列表列表:
testcases = int(input().strip())
stuff = [[int(x) for x in input().strip().split()] for case in range(testcases)]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.