我正在关注 zed shaw 的 learn python hard way 并且正在关注练习 14。这是我正在谈论的程序:
from sys import argv
script, user_name = argv
prompt = '> '
print "Hi %s, I'm the %s script." % (user_name, script)
print "I'd like to ask you a few questions."
print "Do you like me %s?" % user_name
likes = raw_input(prompt)
print "Where do you live %s?" % user_name
lives = raw_input(prompt)
print "What kind of computer do you have?"
computer = raw_input(prompt)
print """
Alright, so you said %r about liking me.
You live in %r. Not sure where that is.
And you have a %r computer. Nice.
""" % (likes, lives, computer)
现在,我使用命令在 powershell 终端中运行这个程序
python e:\python\ex14.py
我收到以下错误消息:
Traceback (most recent call last):
File "e:\python\ex14.py", line 3, in (module)
script, user_name=argv
ValueError: need more than 1 value to unpack.
现在,我不确定问题出在哪里。唯一的原因可能是我正在输入文件路径而不是仅输入文件名。