I keep getting invalid syntax at *args
.
Here's a snippet of the code:
cmd, *args = sys.argv[1:]
globals()[cmd](*args)
I'm trying to pass multiple arguments to the functions in code.
答案 0 :(得分:3)
You're trying to use Extended Iterable Unpacking, which is available starting from Python 3.
You'd replace it with
cmd = sys.argv[1]
args = sys.argv[2:]
globals()[cmd](*args)
to make it work in Python 2.