【发布时间】:2012-04-07 13:57:45
【问题描述】:
我正在关注 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.
现在,我不确定问题出在哪里。唯一的原因可能是我输入的是文件路径,而不是只输入文件名。
【问题讨论】:
-
如果您的目标是学习 Python,我建议您尝试更传统的教程。
-
你能提供一个更传统的教程的链接吗?我是新来的,只是遵循这个网站的一些建议。到目前为止,我喜欢这个教程,但也希望看到一个传统的教程。
-
@agf Learn Python the Hard Way 不是传统的教程吗?
标签: python