Printing help - 打印帮助
In most typical applications, parse_args() will take care of formatting and printing any usage or error messages. However, several formatting methods are available:
在大多数典型应用程序中,parse_args() 将负责格式化和打印任何用法或错误消息。但是,有几种格式化方法可供使用:
ArgumentParser.print_usage(file=None)
Print a brief description of how the ArgumentParser should be invoked on the command line. If file is None, sys.stdout is assumed.
打印如何在命令行上调用 ArgumentParser 的简要说明。如果 file 为 None,则假定为 sys.stdout。
ArgumentParser.print_help(file=None)
Print a help message, including the program usage and information about the arguments registered with the ArgumentParser. If file is None, sys.stdout is assumed.
打印帮助消息,包括程序用法和有关 ArgumentParser 注册的参数的信息。如果 file 为 None,则假定为 sys.stdout。
There are also variants of these methods that simply return a string instead of printing it:
还有这些方法的变体只返回一个字符串而不是打印它:
ArgumentParser.format_usage()
Return a string containing a brief description of how the ArgumentParser should be invoked on the command line.
返回一个字符串,其中包含如何在命令行上调用 ArgumentParser 的简要说明。
ArgumentParser.format_help()
Return a string containing a help message, including the program usage and information about the arguments registered with the ArgumentParser.
返回包含帮助消息的字符串,包括程序用法和有关 ArgumentParser 注册的参数的信息。
invoke [ɪn'vəʊk]:vt. 调用,祈求,引起,恳求