有什么方法可以解决argv拆包问题

时间:2019-04-11 11:02:42

标签: python-3.7

没有足够的值来解压缩argv变量

from sys import argv

script, user_name = argv
prompt = '>'

print("Hi %s I am the %s script." % (user_name, script))

print("I would like to ask you a few questions.")

print("Do you like me %s?" % user_name)
likes = input(prompt)

print("Where do you live %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 live in %r. Not sure where that is.
And you have a %r computer. Nice.
""" % (likes, lives, computer))

错误:

第3行,在     脚本,user_name = argv ValueError:没有足够的值可解包(预期2,得到1)

0 个答案:

没有答案