使用python的optparse模块我想在常规使用输出下面添加额外的示例行.我当前的help_print()输出如下所示:
usage: check_dell.py [options]
options:
-h, --help show this help message and exit
-s, --storage checks virtual and physical disks
-c, --chassis checks specified chassis components
Run Code Online (Sandbox Code Playgroud)
我想在我的工作中包含较少*nix识字用户的用法示例.像这样的东西:
usage: check_dell.py [options]
options:
-h, --help show this help message and exit
-s, --storage checks virtual and physical disks
-c, --chassis checks specified chassis components
Examples:
check_dell -c all
check_dell -c fans memory voltage
check_dell -s
Run Code Online (Sandbox Code Playgroud)
我怎么做到这一点?optparse选项允许哪些选项?当前代码:
import optparse
def main():
parser = optparse.OptionParser()
parser.add_option('-s', '--storage', action='store_true', default=False, help='checks virtual and physical disks') …Run Code Online (Sandbox Code Playgroud)