简体   繁体   English

ValueError : 要解压的值太多

[英]ValueError : too many values to unpack

I dont understand the following code.我不明白以下代码。 when im executing it is giving the value error too many values to unpack当我执行它时给值错误太多的值来解包

train_data=[data, Label]
print train_data
for data, Label in train_data:
     print data
     print Label


 output 
 [array([[23., 114., 49., ..., 61., 66., 75.,],
        [134., 345., 123., ..., 252., 249., 255.],
        ....
        [123., 97., 45., ..., 33., 234.,132.],
        [76., 98., 54., ..., 243., 211.,187.]], dtypye=float32), 
        array([0,0,1,0,2,1,1,0,0,2,2,2,0,0,0,0,2,0,0,2,2,2,0,2,2,1,1,0])]

 ValueError Traceback(most recent call last)
      1. print train_data
  --->2. for data,Label in train_data
 ValueError: too many values to unpack

please help me to solve this issue.请帮我解决这个问题。

Since I don't have your data, I can't try to reproduce your problem.由于我没有您的数据,我无法尝试重现您的问题。 However, I would suggest you try the following.但是,我建议您尝试以下操作。

instead of train_data=[data, Label] use zip(list_a, list_b)而不是train_data=[data, Label]使用zip(list_a, list_b)

Try this and let me know whether it works试试这个,让我知道它是否有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM