复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#!/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输出如下:
复制代码
1
2
3parser.add_argument('-c', action='store_true', default=false)
#python test.py -c => c是true(因为action)
#python test.py => c是false(default)
转载于:https://www.cnblogs.com/fply/p/8352069.html
最后
以上就是温婉烤鸡最近收集整理的关于python 参数解析ArgumentParser的全部内容,更多相关python内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复