I'm trying to use argument parser to parse a 3D coordinate so I can use
--cord 1,2,3 2,4,6 3,6,9
and get
((1,2,3),(2,4,6),(3,6,9))
My attempt is
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--cord', help="Coordinate", dest="cord", type=tuple, nargs=3)
args = parser.parse_args(["--cord","1,2,3","2,4,6","3,6,9"])
vars(args)
{'cord': [('1', ',', '2', ',', '3'),
('2', ',', '4', ',', '6'),
('3', ',', '6', ',', '9')]}
What would the replacement of the comma be?
question from:
https://stackoverflow.com/questions/9978880/python-argument-parser-list-of-list-or-tuple-of-tuples 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…