當我以交互模式使用Ipython運行腳本時,sys.argv
參數列表在執行的交互部分中與在腳本中不同。當在Ipython中處於交互模式時,sys.argv是不同的
這是一個錯誤,還是我做錯了什麼?
謝謝!
[email protected]:~$ cat test.py
import sys
print(sys.argv)
temp = sys.argv
[email protected]:~$ 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']