您的位置:首页 > 移动开发 > Objective-C

TypeError: object of type 'zip' has no len()、'zip' object is not subscriptable

2019-08-20 20:36 2176 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/Moelimoe/article/details/99881373
TypeError: object of type ‘zip’ has no len()、‘zip’ object is not subscriptable
zip 对象没有length属性不可以遍历

代码报错:

print(len(training_data)) # TypeError: object of type 'zip' has no len()
print(training_data[0][0].shape) # TypeError: 'zip' object is not subscriptable

源代码部分代码:

test_data = zip(test_inputs, te_d[1])
return (training_data, validation_data, test_data)

解决方法:zip对象用list包装即可

test_data = list(zip(test_inputs, te_d[1]))
return (training_data, validation_data, test_data)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐