提示和传递练习****
from sys import argv
script, user_name = argv
prompt = ‘>’
print(f’Hi {users_name}. I am the {script} script.;’)
print(“I’d like to ask you a few questions.”)
print(f’Do you like me {user_name} ?’)
likes = input(prompt)
print(‘What kind of computer do you have’)
computer = input(prompt)
print(f"""
Alright, so you said {likes} about liking me.
You live in {lives}. Not sure where that is.
And you have a {computer} computer. Nice.
“”")
终端
“C:\Program Files\Python37\python.exe” C:/Users/星溯/Desktop/新代码小课/ex14.py
Traceback (most recent call last):
File “C:/Users/星溯/Desktop/新代码小课/ex14.py”, line 3, in
script, user_name = argv
ValueError: not enough values to unpack (expected 2, got 1)
进程已结束,退出代码1
本文探讨了Python编程中常见的错误类型,特别是针对参数解包错误进行了深入分析,通过一个具体的示例代码,解释了如何避免此类错误,对于初学者理解Python语法至关重要。
2万+





