标签:des style ar io os sp on bs cti
1.简单示例如下:
from optparse import OptionParser [...] parser = OptionParser() parser.add_option("-f", "--file", dest="filename", help="write report to FILE", metavar="FILE") parser.add_option("-q", "--quiet", action="store_false", dest="verbose", default=True, help="don‘t print status messages to stdout") (options, args) = parser.parse_args()
2. 打印版本
parser = OptionParser(usage="%prog [-f] [-q]", version="%prog 1.0")
<yourscript> --version
标签:des style ar io os sp on bs cti
原文地址:http://my.oschina.net/vnlyzhang/blog/356992