# help - 设置这个选项的帮助信息 # dest - 设置这个选项的值就是解析出来后放到哪个属性中 parser.add_argument("-q", dest="world")
args = parser.parse_args(args) # 如果你没有args参数,那么就使用sys.argv,也就是命令行参数啦。有这个参数,就方便我们调试啊 # args.world就是-q的值啦 # action - The basic type of action to be taken when this argument is encountered at the command line. # const - A constant value required by some action and nargs selections. # 这两个自己看帮助文档啦,比较复杂 # http://docs.python.org/library/argparse.html print args