#!/usr/bin/env python
import sys
import getopt
def main(argv):
#opts, args = getopt.getopt(argv[1:], "h", ['output='])
opts, args = getopt.getopt(argv[1:], "h", ['output=', 'input='])
print opts
print args
for o, a in opts:
print o,a
if o in ('-h'):
print "help"
if o in ('--output'):
print "output=", a
elif o in ('--input'):
print "input=", a
if __name__ == '__main__':
main(sys.argv)
##### zl@zl:~/python/getopt$ python try.py --output=3 --input=1 -h
##### [('--output', '3'), ('--input', '1'), ('-h', '')]
##### []
##### --output 3
##### output= 3
##### --input 1
##### input= 1
##### -h
##### help
##### ref:http://www.tuicool.com/articles/jaqQvq