logo
publist
写文章

简介

该用户还未填写简介

擅长的技术栈

可提供的服务

暂无可提供的服务

Python函数调用出现NameError: name ‘xxx‘ is not defined的解决办法

原因:函数里用的是局部变量,从而函数调用结束后会被销毁。如果不声明是全局变量,那么就会报错:(注意灰色字体注释的地方)def load_data():from keras.datasets import mnist# global train_image, train_lable , test_image, test_lable(train_image, train_lable), (test_i

#python
Python函数调用出现NameError: name ‘xxx‘ is not defined的解决办法

原因:函数里用的是局部变量,从而函数调用结束后会被销毁。如果不声明是全局变量,那么就会报错:(注意灰色字体注释的地方)def load_data():from keras.datasets import mnist# global train_image, train_lable , test_image, test_lable(train_image, train_lable), (test_i

#python
到底了