义乌外贸公司网站,百度竞价推广效果好吗,网站和网页的区别是什么,织梦网站地图如何做当我们执行脚本的时候#xff0c;通常都会执行 python test.py -i xxx -o xxx#xff0c;这里的 -i 和 -o 都是输入参数#xff0c;这到底是怎么传递的呢#xff1f; 本文纯粹记录一下 import argparseif __name__ __main__:print(hello)# 创建AugumentParser… 当我们执行脚本的时候通常都会执行 python test.py -i xxx -o xxx这里的 -i 和 -o 都是输入参数这到底是怎么传递的呢 本文纯粹记录一下 import argparseif __name__ __main__:print(hello)# 创建AugumentParser对象parser argparse.ArgumentParser(descriptionExample script with -i and -o parameters.)# 添加输入参数 -iparser.add_argument(-i,--input,typestr,requiredTrue,helpInput file path)# 添加输出参数 -oparser.add_argument(-o,--output,typestr,requiredTrue,helpOutput file path)# 解析命令行参数args parser.parse_args()# 访问参数input_file args.inputoutput_file args.outputprint(finput file:{input_file})print(foutput file:{output_file})
最后执行代码的时候 python xxx.py -i aaa -o bbb 这样就会输出aaa 和 bbb