0
我得到這個錯誤:
不受約束的方法你好()必須以實例作爲第一個參數來調用(什麼都沒有代替)在python中如何限制靜態方法?
import B
class A():
@staticmethod
def newHello():
A.oldHello() # Here the error
print ' world'
def inject(self):
A.oldHello = B.hello
B.hello = A.newHello
A().inject()
B.hello()
B.py只包含一個函數「你好」打印「你好」
def hello():
print 'hello'
在此先感謝
你嘗試過B帶因爲它表明一個實例?你得到了什麼? – jollarvia 2014-09-26 16:05:04
你的意思是叫oldHello(A())?該函數你好有1個參數,0需要 – user2054758 2014-09-26 18:06:52