python报错:TypeError: ‘NoneType‘ object is not subscriptable

今天在写代码时碰到了这个错误:

 16 Traceback (most recent call last):
 17   File "validation_gan.py", line 193, in 
 18     main(sys.argv)
 19   File "validation_gan.py", line 139, in main
 20     dic_GAN, dic_Geant4 = extract_n_epoch(iEpoch, iEpoch+step, step, gan_data, roo_data)
 21   File "validation_gan.py", line 90, in extract_n_epoch
 22     dic_Geant4[g4_attribute]=data2[start_Epoch:end_Epoch, j]
 23 TypeError: 'NoneType' object is not subscriptable

报这个错误的原因是,This error occurs when you try to subscript an object having “none” value.大意就是我的data2是空的,无法进行切片,然后查了下原因,是data2调用函数返回值时,函数忘了加return data2导致的。

你可能感兴趣的:(debug,python)