Printing help - 打印帮助

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. 调用,祈求,引起,恳求
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值