我对python很陌生,我是通过阅读一本书来学习的(用艰苦的方法学习Python 3)。书中有一个练习(Exercise14)不能使用iOS Pythonista 3运行。
该脚本如下:
from sys import argv
script, user_name = argv
prompt = '> '
print(f"Hi {user_name}, I'm 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(f"Where do you live {user_name}?")
lives = 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.
""")但后来我发现了一个错误:
File "/private/var/mobile/Containers/Shared/AppGroup/726BC931-58AE-44A6-9BE5-067EF23667A4/Pythonista3/Documents/Untitled.py", line 2, in <module>
script, user_name = argv
ValueError: not enough values to unpack (expected 2, got 1)请帮我解决这个问题,我是新来的。
谢谢你们!
发布于 2022-09-23 14:48:50
如果您长时间按下Pythonista上的run ("play")按钮,您可以添加脚本所期望的命令行参数(用户名,默认情况下得到的脚本名称)。
https://stackoverflow.com/questions/73827152
复制相似问题