我对面向对象的世界很陌生,我尝试用python编写代码并从另一个类调用一个类的函数。
霉菌
class A:
def funcA():
return "sometext"
def funcB(self):
self.funcA() # calls func A internally from funcB
第二代码.py
from Mycode import A
class B:
def funcC(self):
A.funcB(self) # it gives error for call funcA() as it is unknown to class B
if __name__ == '__main__':
b=B()
b.funcC()
attributeerror:“b”对象没有“funca”属性在python中的类的作用域是如何工作的?