#!/usr/bin/env python #coding:utf-8 from argparse import ArgumentParser #---------------------------------------------------------------------- def test(zzz): """""" print zzz if __name__ == '__main__': parse = ArgumentParser() parse.add_argument("-a",type=str) args=parse.parse_args() print args.a print "111"
test.py -a abc输出如下:
parser.add_argument('-c', action='store_true', default=false)
#python test.py -c => c是true(因为action)
#python test.py => c是false(default)