Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
部分选项解析(python/getopt)_Python_Getopt - Fatal编程技术网

部分选项解析(python/getopt)

部分选项解析(python/getopt),python,getopt,Python,Getopt,使用Python库/(gnu_)getopt/optparse/argparse,我如何才能最好地排除解析选项-r之后的其余选项和参数,并保持一致(将其转发到另一个子进程、模块等) 调用示例(此处需要粗体部分-它与-r之后的rest真正匹配): program.py-ac cval-bdr“val-ra”文件-droot-are-rest opt-x-yr restargs-z 定义/起始日期: shortopts, longopts = 'abc:d:ehr', ['help'] opts,

使用Python库/(gnu_)getopt/optparse/argparse,我如何才能最好地排除解析选项
-r
之后的其余选项和参数,并保持一致(将其转发到另一个子进程、模块等)

调用示例(此处需要粗体部分-它与
-r
之后的rest真正匹配):

program.py-ac cval-bdr“val-ra”文件-droot-are-rest opt-x-yr restargs-z

定义/起始日期:

shortopts, longopts = 'abc:d:ehr', ['help']
opts, files = getopt.gnu_getopt(argv1, shortopts, longopts)
...
POSIX说“破折号”,所以使用

program.py-ac cval-bdr“val-ra”文件-droot-are--x-yr restargs-z