python报错:TypeError: ‘NoneType‘ object is not subscriptable
程序员文章站
2022-06-21 22:52:44
今天在写代码时碰到了这个错误: 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
上一篇: 初探python——代理
下一篇: FTP和TCP的文件传输效率对比测试分析
推荐阅读
-
python编程排除163邮箱发送邮件报错(AttributeError: ‘tuple‘ object has no attribute ‘encode‘)
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object
-
报错解决Python Error fix-TypeError: _mean() got an unexpected keyword argument ‘dim‘
-
Python报错TypeError: '<' not supported between instances of 'str
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#
-
解决报错:TypeError: argument should be integer or bytes-like object, not ‘str‘
-
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
-
“TypeError: 'dict_keys' object is not subscriptable”
-
python3_opencv_直线检测_HoughLinesP_ 'NoneType' object is not subscriptable
-
‘NoneType‘ object is not subscriptable报错