import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--aa", type=int, help="The number of clients to write from for each ip", required=True)
parser.add_argument("--bb", type=int, help="The number of seconds to run for each ip", required=True)

args = parser.parse_args()

AA = args.aa
BB = args.bb

print(AA,BB)

 

1、正常的输入

D:\python\test\>python zz.py  --aa 2 --bb 25
2 25

 

2、错误的输入的提示

D:\python\test\>python zz.py  --aa 2
usage: zz.py [-h] --aa AA --bb BB
zz.py: error: the following arguments are required: --bb

 

3、脚本的-h的提示

D:\python\test\>python zz.py  -h
usage: zz.py [-h] --aa AA --bb BB

optional arguments:
  -h, --help  show this help message and exit
  --aa AA     The number of clients to write from for each ip
  --bb BB     The number of seconds to run for each ip

 

相关文章:

  • 2021-09-18
  • 2021-05-20
  • 2022-12-23
  • 1970-01-01
猜你喜欢
  • 2021-05-22
  • 2021-08-24
  • 2021-05-30
  • 2021-06-21
  • 2021-05-04
  • 2022-12-23
  • 2021-07-14
相关资源
相似解决方案