[Python] Getting the remaining arguments in argparse

Discussão em 'Python' iniciado por Stack, Fevereiro 12, 2025.

  1. Stack

    Stack Membro Participativo

    I created an argparse.ArgumentParser and added specific arguments like:

    parser.add_argument('-i', action='store', dest='i', default='i.log')
    parser.add_argument('-o', action='store', dest='o', default='o.log')


    But I want to be able to accept any arguments, not just the ones for which I explicitly specified the semantics.

    How can I make it so that any remaining command-line arguments are gathered together and I can access them after parsing?

    Continue reading...

Compartilhe esta Página