python 解析命令行参数
使用argparse包对命令行参数进行解析
使用
argparse.ArgumentParser建立参数对象使用对象的
add_argument方法添加提示信息将参数解析成字典对象
1.创建参数对象
## 创建参数对象
parser=argparse.ArgumentParser(description="find homologous which conserve As Events")2.添加参数
parser.add_argument("-AtBlast",help="At blast out file")
parser.add_argument("-DtBlast",help="Dt blast out file")
parser.add_argument("-D5Blast",help="D5 blast out file")3.解析参数对象
## 解析参数对象
args=parser.parse_args()4.使用参数
注意事项
在添加参数时,不再需要再额外的
-h参数
输出结果
参考
Last updated
Was this helpful?