http://www.blogger.com/post-create.g?blogID=16042244
http://www.javaworld.com.tw/jute/post/view?bid=14&id=88875&sty=3
Ross Wan’s World!
上面寫的是非常詳細的用法
Google support GUI
這是關於寫command line時的參數檢查與設定,對於在linux或是習慣command line開發的人很有幫助~~~~
範例:
import sys
import optparse
import optparse_gui
def main():
usage = "usage: %prog [options] args"
if 1 == len( sys.argv ):
option_parser_class = optparse_gui.OptionParser
else:
option_parser_class = optparse.OptionParser
parser = option_parser_class( usage = usage, version='0.1' )
parser.add_option("-f", "--file", dest="filename", default = r'c:\sample.txt',
help="read data from FILENAME")
parser.add_option("-a", "--action", dest="action",
choices = ['delete', 'copy', 'move'],
help="Which action do you wish to take?!")
parser.add_option("-n", "--number", dest="number", default = 23,
type = 'int',
help="Just a number")
parser.add_option("-v", "--verbose",
action="store_true", dest="verbose",
help = 'To be or not to be? ( verbose )')
options, args = parser.parse_args()
print 'args: %s' % args
print 'options: %s' % options
if '__main__' == __name__:
main()
沒有留言:
張貼留言