【发布时间】:2017-04-13 20:04:55
【问题描述】:
我在 Github gist 上有一个 Python 脚本,我可以使用
从终端卷曲它curl -s https://gist.githubusercontent.com/.../script.py
该脚本有一个执行的 main 函数,我可以将 curl 语句的输出通过管道传递给 Python,Python 将执行该脚本。
curl -s https://gist.githubusercontent.com/.../script.py | python
上述语句有效,但我想为脚本提供一些命令行参数,而无需将其下载到文件中。我面临的问题是 Python 命令将其后面的任何文本视为要执行的内容,而不是管道文件的参数,所以
curl -s https://gist.githubusercontent.com/.../script.py | python arg1 arg2
没有用,也没有
curl -s https://gist.githubusercontent.com/.../script.py arg1 arg2 | python
如何将这两个参数作为标准输入或我的脚本可以读取的命令行选项传递给文件?
【问题讨论】: