我在这里试图解析一些命令行参数,但是我构建的脚本不断删除最后一个参数.
为了保持简单,我重现了这样的问题:
import getopt
argv = ["-c", "config", "-o", "hello", "-e", "fu bar", "-q", "this is a query"]
opts, args = getopt.getopt(argv, "c:o:e:q", ["cfile=", "ofile=", "entry=", "query="])
for opt, arg in opts:
print(opt, arg)
Run Code Online (Sandbox Code Playgroud)
这是我得到的输出:
-c config
-o hello
-e fu bar
-q
Run Code Online (Sandbox Code Playgroud)
我哪里错了?
| 归档时间: |
|
| 查看次数: |
61 次 |
| 最近记录: |