TypeError: object of type 'zip' has no len()、'zip' object is not subscriptable
生活随笔
收集整理的這篇文章主要介紹了
TypeError: object of type 'zip' has no len()、'zip' object is not subscriptable
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
TypeError: object of type ‘zip’ has no len()、‘zip’ object is not subscriptable
zip 對象沒有l(wèi)ength屬性不可以遍歷
代碼報錯:
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)總結
以上是生活随笔為你收集整理的TypeError: object of type 'zip' has no len()、'zip' object is not subscriptable的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html 网页制作标签,html网页制作
- 下一篇: 提取多个字段_【博客翻译】建筑物轮廓线提