首页 > 编程语言 > 详细

Python日常Bug集

时间:2018-03-08 11:10:33      阅读:175      评论:0      收藏:0      [点我收藏+]

1.TypeError: ‘int‘ object is not iterable

 场景示例:

data = 7
for i in data:
    print(i)

# 原因:直接对int数据进行迭代造成的,修改为:
for i range(data):
    print(i)

2.TypeError: ‘list‘ object is not callable

场景示例:

data= [2,3,4,5,6]
for index,item in enumerate(data):
    print(data(index))

# 原因:对于可迭代的数据集,使用索引取数据直接使用data(index)圆括号造成
# 解决:将圆括号改为中括号

 

Python日常Bug集

原文:https://www.cnblogs.com/maria-ld/p/8527092.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!