#!/usr/bin/env python
import optparse
if __name__ == "__main__":
usage = "Usage %prog [options]"
p = optparse.OptionParser(usage=usage)
p.add_option("-t","--test",action="store_true",dest="dotest",default=False,help="test case")
(options,args) = p.parse_args()
if options.dotest:
print 'do test'
else:
print 'No action'
在命令列執行:
>./test.py -t
do test
>./test.py -h
usage: Usage test.py [options]
options:
-h, --help show this help message and exit
-t, --test test case
>
No comments:
Post a Comment