import argparse

Create the parser

parser = argparse.ArgumentParser(description='Process some integers.')

Add arguments to the parser

parser.add_argument('integers', metavar='N', type=int, nargs='+', help='an integer for the accumulator') parser.add_argument('--sum', dest='accumulate', action='store_const', const=sum, default=max, help='sum the integers (default: find the max)')

Parse the command-line arguments

args = parser.parse_args()

Print the result

print(args.accumulate(args.integers)

import argparse

原文地址: http://www.cveoy.top/t/topic/hC5o 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录