python argparse 模块使用

import argparse

argparse = argparse.ArgumentParser(description="Human Para")
argparse.add_argument('--keyword',help="requeied", type=str, required=True)
argparse.add_argument('--top', type=int,default=100)
args = argparse.parse_args()

print(args.keyword)

print(args.top)

命令行如下

1.py --keyword 123 --top 123

你可能感兴趣的:(Python)