有没有办法安静地启动 python,也许是通过设置一些环境变量或提供命令行选项?而不是看到这个:
wim@SDFA100461C:/tmp$ python
Python 2.7.5+ (default, Sep 19 2013, 13:48:49)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
有时我想要这种行为,直接提示:
wim@SDFA100461C:/tmp$ python
>>>
我也对 ipython
的答案感兴趣。
最佳答案
这似乎可以解决问题:
C:\Users\Bartek>python -i -c ""
>>> print "I ♥ Python!"
I ♥ Python!
>>> exit()
C:\Users\Bartek>
-i
选项描述为:
-i : inspect interactively after running script; forces a prompt even if stdin does not appear to be a terminal; also PYTHONINSPECT=x
所以只要你在终端上,它似乎没有任何警告。
ipython
有一个简单的 --no-banner
选项:
C:\Users\Bartek>ipython --no-banner
In [1]: print "I <3 Python!"
I <3 Python!
In [2]: exit()
C:\Users\Bartek>
虽然它似乎不支持 Unicode ;)
关于python - 如何悄悄启动Python REPL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20948349/