I am obviously new to python and I've spent the last 1.5 hours beating my head against the wall trying to get this exercise done. It should be relatively simple, and I'm sure using an IDE when I'm new is probably not doing me any favors.
Basically I have this script:
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
I type the above in the editor and then I have the file saved as "ex13.py". When I then try to run the script in the python console I am continually told that the name is not defined. I would really appreciate any help getting this resolved, I am basically stuck and can't progress until I figure out how to run this damn script in pycharm.
Under the run dropdown menu at the top of the pycharm IDE you should find edit configurations. Click on that and write your three arguments in script paramaters. Then run it
in that book pointed you need pass three argument in terminal like this
python ex13.py first 2nd 3rd
and if you pass more than 3 argument like what am i did, it will make you an error, like this:
python .\ex13.py first 2nd 3rd 4th
Traceback (most recent call last):
File ".\ex13.py", line 3, in <module>
script,first,second,third= argv
ValueError: too many values to unpack
so, pass just three argument according to that code in book, Ex13, you'll see it work
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.