GJ.*_*GJ. 3 python bash shell ipython
我试过
echo "print 'hello'" | ipython
Run Code Online (Sandbox Code Playgroud)
它运行命令,但 ipython 之后立即退出。
有任何想法吗?谢谢!
编辑: 我实际上需要将命令传递到交互式 Django shell,例如:
echo "print 'hello'" | python manage.py shell
Run Code Online (Sandbox Code Playgroud)
所以建议的 -i 开关 gimel 似乎不起作用(shell 在执行后仍然退出)
使用标准解释器使用的相同标志,-i
.
-i
当脚本作为第一个参数传递或使用 -c 选项时,在执行脚本或命令后进入交互模式,即使 sys.stdin 看起来不是终端。未读取 PYTHONSTARTUP 文件。
一个 Linux 示例,使用-c
命令行标志:
$ ipython -i -c 'print "hello, ipython!"'
hello, ipython!
In [2]: print "right here"
right here
In [3]:
Run Code Online (Sandbox Code Playgroud)