Chinaunix首页 | 论坛 | 博客
  • 博客访问: 388133
  • 博文数量: 99
  • 博客积分: 5134
  • 博客等级: 大校
  • 技术积分: 1607
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-30 09:31
文章分类

全部博文(99)

文章存档

2011年(48)

2010年(40)

2009年(10)

2008年(1)

分类:

2010-11-29 15:37:23

import getopt, sys

def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="])
    except getopt.GetoptError as err:
        # print help information and exit:
        print(err) # will print something like "option -a not recognized"
        useage()
        sys.exit(2)
    output = None
    verbose = False
    for o, a in opts:
        if o == "-v":
            verbose = True
        elif o in ("-h", "--help"):
            useage()
            sys.exit()
        elif o in ("-o", "--output"):
            output = a
        else:
            assert False, "unhandled option"
    # ...

def useage():
    """disapper help message here
    
    ."""
    print(useage.__doc__)


if __name__ == "__main__":
    main()

阅读(593) | 评论(0) | 转发(0) |
0

上一篇:python logging

下一篇:The Python Debugger

给主人留下些什么吧!~~