argparse with multiple optional flags in one dash
问题 Is it possible to associate multiple flags with a single dash in argparse as in this standard Linux argument style? tar -xvf some_filename.tar 回答1: This will do the trick. Most likely, you didn't include the short form for each argument. import argparse parser = argparse.ArgumentParser(description='... saves many files together...') parser.add_argument('--extract', '-x', action='store_true', help='extract files from an archive') parser.add_argument('--verbose', '-v', action='store_true', help