다음 코드에서 마지막 줄의 실행에서 오류가 발생하는 이유는 무엇입니까? x.bf()의 점 연산자가 인스턴스 'x'를 함수 bf (예 : x.af())로 전달해야합니까?다음 코드에서 마지막 줄의 실행에서 오류가 발생하는 이유는 무엇입니까?
class A:
a = 6
def af (self):
return "Hello-People"
class B:
b = 7
def bf (self):
return "Bye-People"
>>> x = A()
>>> b = B()
>>> x.bf = B.bf
>>> x.bf()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: bf() missing 1 required positional argument: 'self'
Google 오류입니다. – Maroun