Reputation: 61
Hey guys I was trying to use the argument variable in Python however am unable to execute the program at the terminal.
Program:
from sys import argv
script,first,second,third = argv
print "The script is called:", script
print "Your first variable is:", first
print "Your second variable is:", second
print "Your third variable is:", third
Output:
>>> execfile("lesson13.py","dog","cat")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: must be dict, not str
>>>
Upvotes: 1
Views: 4923
Reputation: 798606
execfile()
doesn't take command arguments. Try using subprocess
instead.
Upvotes: 4