Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法argparse将多个参数作为一个参数传递?也就是说,我想
argparse
foo bar baz
argparse通过_
"bar baz"
作为论据。
是的 usingnargs="+"将允许您发送任意数量的参数。
nargs="+"
不过,您将收到它们作为 python 列表。
像这样:-
parser.add_argument("foo", help="Give me an arbitrary number of arguments", nargs="+")