- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我定义了一个带有描述、选项和结尾的解析器。当我使用 --help 运行应用程序时,它会按预期输出关于 epilog 的帮助。但是,如果 --help 与 --verbose 一起出现,我只想查看结语。使用 argparse 实现此目的的正确方法是什么?
# example code in file test
import argparse
parser = argparse.ArgumentParser( description='description', epilog='epilog' )
parser.add_argument('-v', '--verbose', action='store_true', help='verbose help')
parser.parse_args()
当我按如下方式运行测试时
$ python test -h
它产生
usage: test [-h] [-v]
description
optional arguments:
-h, --help show this help message and exit
-v, --verbose verbose help
epilog
然而,我想看到的是
usage: test [-h] [-v]
description
optional arguments:
-h, --help show this help message and exit
-v, --verbose verbose help
仅在我运行时显示结尾
$ python test -h -v
最佳答案
<选择。我知道这样做的唯一方法是自己编写帮助输出:
import argparse
parser = argparse.ArgumentParser(
description='description',
add_help=False )
parser.add_argument(
'-h', '--help',
action=store_true,
dest='show_help')
parser.add_argument(
'-v', '--verbose',
action='store_true',
help='verbose help')
args = parser.parse_args()
if args.show_help:
if args.verbose:
print '%s\n%s' % (parser.format_help(), 'epilog')
else
parser.print_help()
sys.exit(0)
关于 python argparse : print epilog only when verbose,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36738309/
pod update --verbose 未完成,挂起。 CDN: trunk Relative path: Specs/7/4/b/GoogleToolboxForMac/2.1.2/Googl
我正在导入 Carbon进入我的 PowerShell 脚本;但是,当使用 -Verbose 运行我的脚本时,Carbon 也会输出很多 VERBOSE 语句。 是否可以静默导入模块,以便我可以忽略导
我正在创建一个调用Write-Verbose的.ps1脚本。我希望能够启用/禁用这些功能。 我希望调用脚本时可以传递-Verbose标志,并且一切正常。不幸的是,事实并非如此。 详细消息不会写出到主机
我们正在尝试用我们的 WAS(Websphere 应用程序服务器)实例调试一些严重的类加载器问题。 为此,我们提供了选项 -verbose:class 以查看 WAS 从何处加载哪个类。 对于大多数类
Powershell 中详细输出的默认颜色(例如 Write-Verbose 或 -Verbose 开关)是黄色的。这使其看起来像警告,尽管它并不重要。 如何更改详细输出的默认颜色? 最佳答案 这是可
根据回答like this one和我自己的经验,Powershell 可以自动传播 -Verbose(和 -Debug),非常方便。但是,当我想要将详细程度传播到的函数位于模块中时,这将停止工作。用
有没有一种简单的方法可以让 -Verbose 切换到 Powershell 中的其他函数调用“直通”? 我知道我可以在 $PSBoundParameters 中搜索标志并执行 if 语句: [Cmdl
也许在 PowerShell 中没有办法做到这一点。 如果我有文件 verboseTest.ps1 [CmdletBinding()] # CmdletBinding attribute ena
考虑重新设计数据库。想知道与以下内容有什么区别/注意事项: users fields ----- ------ id id user_id
我有一个冗长的 (re.X) 标记的正则表达式抛出异常,即使它看起来等同于它的压缩版本。 (我从后者构建了前者。) 精简版: import re test = 'catdog' test2 = 'do
我运行了这个测试脚本: use strict; use warnings; use Test::More tests => 3; use Carp; ok(1<2); pass(); fail();
我正在制作一个小型系统,我希望能够在整个系统中切换“详细”文本输出。 我创建了一个名为 globals.h 的文件: namespace REBr{ extern bool console_v
因此,我有一个包含大量调试输出的脚本,我可以使用 -v 标志打开/关闭这些输出。我当前的代码如下所示: def vprint( obj ): if args.verbose:
我知道 ansible -vvv 选项,但我不想看到所有命令的详细输出,我只想在任务失败时查看详细信息。 我怎样才能做到这一点? 附言。请提供可扩展的解决方案,必须编辑每个任务没有任何意义。 最佳答案
我正在使用 ant -f build.xml 运行一个 ant 脚本。该脚本应该编译我的项目并生成一个 jar 文件,但是在 ant 开始生成 jar 文件几秒钟后,该项目被终止,我在控制台中看到的只
我刚刚开始构建我的第一个 Rakefile(makefile 的 Ruby 版本),我想使用详细模式(如 makefile -V 或 bash -x)轻松调试我的脚本,是否有这样做的选项 ruby ?
本文整理了Java中org.zeromq.ZLoop.verbose()方法的一些代码示例,展示了ZLoop.verbose()的具体用法。这些代码示例主要来源于Github/Stackoverflo
我希望我的 ROS 包中的特定节点在 DEBUG 详细级别显示输出,而其他节点在 INFO 级别显示。我知道 rosconsole configuration file ,并且能够为包设置详细程度:
MS SQL Server 是否有一些配置选项可以启用更详细的错误消息。 具体示例:我想查看在插入期间违反约束的插入记录的实际字段值,以帮助追踪我无法重现的存储过程中的错误。 最佳答案 我不相信有任何
我正在学习 Coq 和我正在学习的书,( CPDT )大量使用了 auto在证明中。 由于我正在学习,因此我认为了解确切内容可能对我有帮助 auto在幕后做(越早越好)。有没有办法强制它准确显示它用来
我是一名优秀的程序员,十分优秀!