gpt4 book ai didi

ipython - 为什么 `ipython foo.py bar.py` 只打印 `foo.py` 的输出?

转载 作者:行者123 更新时间:2023-12-02 02:04:51 27 4
gpt4 key购买 nike

IPython 0.13.1 文档说:

$ ipython -h
...
Usage

ipython [subcommand] [options] [files]

If invoked with no options, it executes all the files listed in sequence
and exits, use -i to enter interactive mode after running the files.
...

我有两个文件 foo.pybar.py

foo.py:

print "Hi, I'm foo."

bar.py:

print "Hi, I'm bar."

我希望以下内容以相应的顺序打印两个文件输出。相反,我只从命令行给出的第一个文件中获取输出。

$ ipython foo.py bar.py
Hi, I'm foo.

$ ipython bar.py foo.py
Hi, I'm bar.

这是实现错误、文档错误还是用户误解?如果是后者,我应该怎么做?

最佳答案

这是文档故障,由 this Pull Request 修复.命令

$> ipython [-i] script.py script2.py ...

行为与命令完全相同

$> python [-i] script.py script2.py ...

其中,script.py 运行,sys.argv['script.py', 'script2.py', '...'] ,如果指定了 -i,它会在运行脚本后进入交互式 session 。

关于ipython - 为什么 `ipython foo.py bar.py` 只打印 `foo.py` 的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15577189/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com