我有一个代码,它包含以下参数:
parser = argparse.ArgumentParser()
requiredNamed = parser.add_argument_group('required named arguments')
requiredNamed.add_argument('--input_feed', help='''Please provide an input csv file for automatic database creation such as follow: \n environment, database_name, location \n
ENV, d_wc_wrk_pic, '/data/dev/wc/storage/work/d_wc_wrk_pic'
''',required=True)
args = parser.parse_args()
标准输出如下:
当我键入--help命令时,提示后面没有新行吗?有人能给我建议一个方法来修正这个新行错误吗?你知道吗
在
argparse
模块中,HelpFormatter类中有一个方法:虽然帮助消息包含新行,但是
_split_lines
方法将它们替换为空格,然后使用textwrap
模块再次拆分行。你知道吗为了避免直接修改
argparse
moudle的代码,可以使用称为注入的技巧:help
输出:相关问题 更多 >
编程相关推荐