My question is about argparse and how to use multiple choices.
So I declare two choices --country
and --city
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--country', dest='country', type=str, metavar='')
parser.add_argument('--city', dest='city', type=str, metavar='')
I then declare it into the script few lines below:
if args.country:
# Do this
elif args.city:
# Do this
But it is not working and the script is executing the first and the second option. It seems so easy to me. Where am I wrong?
Aucun commentaire:
Enregistrer un commentaire