python调用方法或者变量时出现未定义异常的原因,可能会是没有正确实例化
当引用某个模块时
例如
Testpython import test class test(object): def __init__(): …… self.mimi = test def test1(): …… test2 = self.mimi.write()
那么在另一个文件中使用Testpython该文件的时候一定要注意实例化类test
import Testpython action11 = Testpython.test()
否则会出现__init__有定义但是运行提示AttributeError: 'str' object has no attribute……的情形

浙公网安备 33010602011771号