TypeError: unbound method must be called with class instance 1st argument
2014-07-18 13:51
751 查看
引出此类型的错误可能很多,我的原因如下
1.定义一个Python类
2. 使用类
创建实例的时候,忘记加上括号().所以出错,当然单独写出来的时候,很容易发现,但是在一个复杂逻辑的背景下,很难觉察。
正确的如下:
1.定义一个Python类
class test: def call_test(self): print("test")
2. 使用类
test_instance = test() test_instance.call_test()
创建实例的时候,忘记加上括号().所以出错,当然单独写出来的时候,很容易发现,但是在一个复杂逻辑的背景下,很难觉察。
正确的如下:
test_instance = test() test_instance.call_test()
相关文章推荐
- TypeError: unbound method x must be called with x instance as first argument (got nothing instead)
- TypeError: unbound method Find() must be called with Solution instance as fi
- TypeError: unbound method a() must be called with A instance as first argument (got nothing instead)
- TypeError: unbound method func1() must be called with base1 instance as first argument (got nothing
- super() fails with error: TypeError “argument 1 must be type, not classobj”
- 关于TypeError: strptime() argument 1 must be str, not bytes解析
- TypeError: strptime() argument 0 must be str, not class 'bytes'解决办法
- TypeError: dist must be a Distribution instance
- java.lang.IllegalArgumentException: At least one handler method must be found in class [class SayThr
- TypeError: write() argument must be str, not bytes
- BUG!!!======> syncdb 时 “ TypeError: decode() argument 1 must be string, not None ”
- [转载]python中super出现的TypeError: must be type, not classobj 原因及解决
- Error: A project with an Output Type of Class Library cannot be started directly
- Facebook-在使用图谱API访问App数据提示“This method must be called with an app access_token.”
- TypeError: dist must be a Distribution instance
- Function importPackage must be called with a package; had "[JavaClass java.util.ArrayList]"
- Python错误TypeError: write() argument must be str, not bytes
- python2.7 使用super关键词 报错 TypeError: must be type, not classobj 解决办法
- docx2txt TypeError: write() argument must be str, not bytes
- 关于TypeError: strptime() argument 1 must be str, not bytes解析