我在这段代码中发现了奇怪的行为:
images = dict(cover=[],second_row=[],additional_rows=[])
for pic in pictures:
if len(images['cover']) == 0:
images['cover'] = pic.path_thumb_l
elif len(images['second_row']) < 3:
images['second_row'].append(pic.path_thumb_m)
else:
images['additional_rows'].append(pic.path_thumb_s)
我的web2py应用程序给了我这个错误:if len(images['cover']) == 0:
TypeError: object of type 'NoneType' has no len()
我不知道这个有什么问题。也许是某个范围的问题吗?