简体   繁体   English

在Jupyter Notebook中运行单元格时,是否可以通过命令行参数?

[英]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.

相关问题 从 Jupyter 笔记本运行 Windows 命令行和 arguments - Running a Windows command line with arguments from Jupyter notebook 在命令行中执行Jupyter Notebook - Executing Jupyter notebook in command line 当单元格在 VSCode Jupyter Notebook 中完成执行时,有没有办法收到通知? - Is there a way to be notified when a cell finishes execution in VSCode Jupyter Notebook? 在 jupyter 笔记本中运行 %%cython 时,“命令‘gcc’失败,退出状态为 1” - "command 'gcc' failed with exit status 1" when running %%cython in jupyter notebook 从命令行调用 jupyter notebook 时在 conda 中打开它 - when calling jupyter notebook from command line open it in conda csv 从命令行执行 jupyter notebook 时导出失败 - csv export failing when executing jupyter notebook from command line 有没有一种方法可以将整个jupyter笔记本的输出保存到txt文件或类似文件中,而无需使用命令行,而是从笔记本内部进行保存? - Is there a way to save the output of a whole jupyter notebook to a txt file or similar without using command line but from inside the notebook? jupyter notebook 的 cell 没有运行。 文件未找到错误 - The cell of jupyter notebook is not running. FileNotFoundError 在命令行上安装了一个 package 并且可以通过命令行导入它。 在 jupyter notebook 中导入时收到 ModuleNotFoundError - Installed a package on command line and can import it via command line. Receive ModuleNotFoundError when importing in jupyter notebook 如何在 jupyter notebook 中为 SQL 行魔术、单元魔术和自定义命令添加语法高亮? - How to add syntax highlight to SQL line magic, cell magic and custom command in jupyter notebook?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM