zoukankan      html  css  js  c++  java
  • python之脚本参数optparse

    import optparse
    usage = "myprog[ -f <filename>][-s <xyz>] arg1[,arg2..]"
    opter=optparse.OptionParser(usage)
    opter.add_option("-f","--format",action="store_true",dest="format",help="format print")
    opter.add_option("-t", "--table", action="store", type="string", dest="table",help=u"输入一个表名")
    opter.add_option("-q", "--query", action="store", type="string", dest="term",help=u"查询的关键字")
    opter.add_option("-o", "--output", action="store", type="string", dest="outfile",help=u"输出文件")
    opt,args=opter.parse_args()
    

    输入:-h

    Options:
    -h, --help show this help message and exit
    -f, --format format print
    -t TABLE, --table=TABLE
    输入一个表名
    -q TERM, --query=TERM
    查询的关键字
    -o OUTFILE, --output=OUTFILE
    输出文件

  • 相关阅读:
    hrbust 1558 小背包(简单01背包)水坑
    hrbust 1174泉水(DFS深度优先搜索)
    HDU 1115
    HDU 4273
    HDU 2912
    POJ 3528
    HDU 1912
    HDU 4741
    HDU 4617
    POJ 1755
  • 原文地址:https://www.cnblogs.com/similarface/p/5436065.html
Copyright © 2011-2022 走看看