使用参数启动python shell

使用参数启动python shell,python,linux,shell,terminal,Python,Linux,Shell,Terminal,在linux中是否可以在没有文件的情况下向python传递参数?我当前无法创建文件或更改权限,我不想在代码中这样写: import sys sys.argv = ["arg1", "arg2", ...] 我想在启动shell时移交参数: python <arguments> python 若将命令行参数传递给交互式shell是最佳做法,那个么这是有问题的,但确实可以通过传递-而不是脚本文件名: $ python - a1 a2 Python 2.7.14 (default, S

在linux中是否可以在没有文件的情况下向python传递参数?我当前无法创建文件或更改权限,我不想在代码中这样写:

import sys
sys.argv = ["arg1", "arg2", ...]
我想在启动shell时移交参数:

python <arguments>
python

若将命令行参数传递给交互式shell是最佳做法,那个么这是有问题的,但确实可以通过传递
-
而不是脚本文件名:

$ python - a1 a2
Python 2.7.14 (default, Sep 23 2017, 22:06:14) 
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.argv
['-', 'a1', 'a2']

如果将IPython用作交互式shell,则可以使用
%run
magic命令将参数传递给运行的脚本:

In [1]: %run myscript.py arg1 arg2 ...

(我不太清楚您想要实现什么,但您可能想将参数传递给某个脚本。)

这些“参数”会做什么?
python myscript.py arg1 arg2 arg3
python-arg1 args2…
这就是我想要的。谢谢