TypeError: unbound method a() must be called with A instance as first argument (got nothing instead)
2015-03-28 11:40
513 查看
错误如下:
[/code]
>>> class A: def a(self): print("I'm a") >>> A.a() Traceback (most recent call last): File "<pyshell#10>", line 1, in <module> A.a() TypeError: unbound method a() must be called with A instance as first argument (got nothing instead) 错误原因:函数a()非静态方法,故需实例化然后才能使用,改正如下: class A: def a(self): print("I'm a") obj = A() obj.a() 或者将a()改为静态方法即可,如下: [code]class A: @staticmethod def a(): print ("I'm a") A.a()
[/code]
相关文章推荐
- TypeError: unbound method x must be called with x instance as first argument (got nothing instead)
- TypeError: unbound method func1() must be called with base1 instance as first argument (got nothing
- TypeError: unbound method Find() must be called with Solution instance as fi
- TypeError: unbound method must be called with class instance 1st argument
- Facebook-在使用图谱API访问App数据提示“This method must be called with an app access_token.”
- 如何获取app access_token(针对这样的错误This method must be called with an app access_token.)
- When using SqlDependency without providing an options value, SqlDependency.Start() must be called prior to execution of a command added to the SqlDependency instance.
- error 'there is already an open datareader associated with this command which must be closed first'
- webview在红米3上面打开显示错误A WebView method was called on thread 'Thread-9191'. All WebView methods must be
- There is already an open DataReader associated with this Command which must be closed first." exception in Entity Framework
- There is already an open DataReader associated with this Command which must be closed first的错误解决办法
- LINQ链接数据库出错(There is already an open DataReader associated with this Command which must be closed first )
- In-App Purch - Your first In-App Purchase(s) must be submitted with a new app version...问题解决方案
- Function importPackage must be called with a package; had "[JavaClass java.util.ArrayList]"
- Function importPackage must be called with a package; had "[JavaClass java.util.ArrayList]"
- There is already an open DataReader associated with this Connection which must be closed first
- EF "There is already an open DataReader associated with this Command which must be closed first."
- Android异常解决--A WebView method was called on thread 'JavaBridge'. All WebView methods must be called
- Function importPackage must be called with a package; had "[JavaClass java.util.ArrayList]"
- Function importPackage must be called with a package; had "[JavaClass java.util.ArrayList]"