gpt4 book ai didi

python - 值错误 : too many values to unpack (expected 2)

转载 作者:行者123 更新时间:2023-11-28 20:07:13 25 4
gpt4 key购买 nike

line="101 : johnny 'wave-boy' jones:usa:8.32:fish:21"
s={}
(identity,name,country,average,boardtype,age)=line.split()
print(identity)

我的输出是:

Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
(identity,name,country,average,boardtype,age)=line.split()
ValueError: need more than 5 values to unpack

最佳答案

您在空白字符处拆分行。我想你想用冒号分割它,你可以通过

identity, name, country, average, boardtype, age = line.split(':')

关于python - 值错误 : too many values to unpack (expected 2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18513494/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com