如何将命令行参数传递给ipython

如何将命令行参数传递给ipython,第1张

如何将命令行参数传递给ipython

您可以

--
在此之前再使用一个选项

ipython  script.py -- --argument blah

的帮助

Ipython

ipython [subcommand] [options] [-c cmd | -m mod | file] [--] [arg] ...If invoked with no options, it executes the file and exits, passing theremaining arguments to the script, just as if you had specified the samecommand with python. You may need to specify `--` before args to be passedto the script, to prevent IPython from attempting to parse them. If youspecify the option `-i` before the filename, it will enter an interactiveIPython session after running the script, rather than exiting.

演示

$ cat script.py import sysprint(sys.argv)$ ipython  script.py -- --argument blah['script.py', '--argument', 'blah']$ ipython  script.py -- arg1 arg2['script.py', 'arg1', 'arg2']


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5675055.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存