当我在交互模式下使用Ipython运行脚本时,
这是一个错误吗,还是我做错了什么?
谢谢!
sys.argv
参数列表在执行交互部分时与脚本中不同。这是一个错误吗,还是我做错了什么?
谢谢!
oskar@RR06:~$ cat test.py
import sys
print(sys.argv)
temp = sys.argv
oskar@RR06:~$ ipython -i test.py -- foo bar
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
Type "copyright", "credits" or "license" for more information.
IPython 4.2.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
['/home/oskar/test.py', 'foo', 'bar']
In [1]: temp
Out[1]: ['/home/oskar/test.py', 'foo', 'bar']
In [2]: sys.argv
Out[2]: ['/usr/local/bin/ipython', '-i', 'test.py', '--', 'foo', 'bar']