List of arguments with argparse
问题 I'm trying to pass a list of arguments with argparse but the only way that I've found involves rewriting the option for each argument that I want to pass: What I currently use: main.py -t arg1 -a arg2 and I would like: main.py -t arg1 arg2 ... Here is my code: parser.add_argument("-t", action='append', dest='table', default=[], help="") 回答1: Use nargs: ArgumentParser objects usually associate a single command-line argument with a single action to be taken. The nargs keyword argument