设为首页 加入收藏

TOP

Python的OptionParser模块教程(二)
2023-07-25 21:28:23 】 浏览:46
Tags:Python OptionParser
;, action="store_true", dest="verbose", default=True)

help — 指定帮助文档

parser.add_option("-f", "--filename",
                  metavar="FILE",
                  help="write output to FILE"),

optparse解析到 -h 或者 —help 命令行参数时,调用 parser.print_help()输出 程序帮助信息。help字段很有用。
metavar — 提示用户期望参数

Group — 给参数分组

group = OptionGroup(parser, ``Dangerous Options",
                    ``Caution: use these options at your own risk."
                    ``It is believed that some of them bite.")
group.add_option(``-g", action="store_true", help="Group option.")
parser.add_option_group(group)
首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Python爬取往期股票数据,分析中.. 下一篇Python之open()/OS

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目