我正在尝试使用 tkinter 和 python 制作音乐应用程序,但我无法摆脱“ValueError:没有足够的值来解压(预期 2,得到 1)”错误。看看我的代码,您就会清楚我在处理什么。
机制很简单,首先,我通过字典(列表)显示歌曲选项,然后在输入后,“j”的对应值,(例如,如果输入为 1,则 j 为 1,j 的对应值为i) 保存为歌曲名,通过播放音乐来执行程序。
list = {
'1':'Say You Won t Let Go.mp3','2':'In the Jungle the mighty jungle.mp3'
}
lost = ''
print(list)
print("which one?")
this_one = int(input(''))
for j,i in list:
if j == this_one:
lost = i
原文由 BigPy 发布,翻译遵循 CC BY-SA 4.0 许可协议
干得好,
dict.items()
返回 2 个对象(键,值)的元组。