小编use*_*512的帖子

在 python 中使用 optparse 时抑制帮助中的选项之一

考虑以下:

parser.add_option("-f", "--file", "--secret", action = "append", type = "string", dest = "filename", default = [], help = "specify the files")
Run Code Online (Sandbox Code Playgroud)

我想在调用帮助时向用户隐藏 --secret 选项。我可以通过以下方式做到这一点吗?

parser.add_option("-f", "--file", action = "append", type = "string", dest = "filename", default = [], help = "specify the files")
parser.add_option("--secret", action = "append", type = "string", dest = "filename", default = [], help = "specify the files")
Run Code Online (Sandbox Code Playgroud)

我这样做是否遗漏了任何隐藏的问题?如果是这样,任何人都可以建议一种替代方法来实现这一目标。

python optparse

4
推荐指数
1
解决办法
2246
查看次数

标签 统计

optparse ×1

python ×1