2 f826539110 f826539110 于 2016.03.31 14:24 提问

本方法学python 练习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 s few questions.")
print("Do you like me %s?"%user_name)
likes = input(prompt)

print("Where do you like %s?"%user_name)
lives = input(prompt)

print("What kind of computer do you have?")
computer = input(prompt)
print("""
Alright,so you said %r about liking me.
You libe in %r.Not sure where that is.
And you have a %r computer.Nice.
""" %(likes,lives,computer))
报错:
Traceback (most recent call last):
File "ex14.py", line 3, in
script,user_name = argv
ValueError: not enough values to unpack (expected 2, got 1)

3个回答

oyljerry
oyljerry   Ds   Rxr 2016.03.31 15:19

你传的参数有两个元组吗,错误提示参数不够

adogwtf
adogwtf   2016.03.31 15:41

你用的python xxx.py运行的吧, python是不算在argv里的哦

用python xxx.py aa就可以正常运行了

sinat_29379695
sinat_29379695 小白请教,具体怎么修改?我尝试了很多方法都不行,先谢了。
一年多之前 回复
sinat_29379695
sinat_29379695   2016.05.10 23:34

请问这个问题具体你是怎么解决的?

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!