我在这段代码中看到了奇怪的行为:
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()
我无法弄清楚这有什么问题。也许一些范围问题?