如何修复“ValueError:没有足够的值来解压(预期 2,得到 1)”

Big*_*gPy 6 python python-3.x

我正在尝试使用 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
Run Code Online (Sandbox Code Playgroud)

Ibt*_*hir 3

干得好,

songs = {"1": "Say You Won t Let Go.mp3",
         "2": "In the Jungle the mighty jungle.mp3"}
lost = ''
print(songs)
this_one = int(input("Which One? "))

for number, song in songs.items():
    if number == this_one:
        lost = song
Run Code Online (Sandbox Code Playgroud)

dict.items()返回 2 个对象的元组(键、值)。