讨论数量:
It already told you that
the following arguments are required: -c/--config
D:\>type test.py
import argparse
parser = argparse.ArgumentParser(description='Train config file')
parser.add_argument('-c', '--config', help='path to config file', required=True)
arg = parser.parse_args()
config_path = arg.config
print(f"Path is {config_path}")
D:\>python test.py
usage: test.py [-h] -c CONFIG
test.py: error: the following arguments are required: -c/--config
D:\>python test.py -c c:\windows
Path is c:\windows
D:\>python test.py --config c:\windows
Path is c:\windows
推荐文章: