为另一个使用argparse的python脚本生成命令行参数

时间:2018-09-29 05:15:10

标签: python argparse

我正在编写一个python(包装器)脚本来调用其他python脚本,这些脚本通过命令行接收参数并在内部使用argparse。

在包装器的python代码中从变量生成这些命令行,然后传递到其他python脚本的最佳方法是什么?

我当前正在使用字符串连接,因此我不确定这是否是最佳方法。然后,我使用子进程调用其他python脚本。

例如:hello.py使用argparse并需要一些定义为的参数: --test-gen,--interations,--data-file

我需要从wrapper.py生成命令,这实际上将基于test-gen,interations和数据文件列表的变量生成以下命令

python hello.py --test-gen 89.3 --interations 250 --data-file /home/ubuntu/stream.csv

请注意,我已阅读:Run a python script from another python script, passing in args,但这并不涉及如何优化命令行参数的生成。

0 个答案:

没有答案
相关问题