欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-03-03 22:01:01
今天在写代码时碰到了这个错误: 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,...

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

 16 Traceback (most recent call last):
 17   File "validation_gan.py", line 193, in <module>
 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导致的。

本文地址:https://blog.csdn.net/Dr_jiabin/article/details/107631335

相关标签: debug python