ArgumentParser添加选项并解析

34 阅读1分钟
args = argparse.ArgumentParser(description="Demo prog.")
args.add_argument('-p', "--platform", choices=['xhs', "weibo"], type=str, help="help str, this is platform",default="weibo")
# a = args.parse_args(["-p", "xhs"])
a = args.parse_args()
print(a)