|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
class C:
def _init_(self,x,y):
self.x = x
self.y = y
def add(self):
return self.x+self.y
def mul(self):
return self.x*self.y
KeyboardInterrupt
c=C(2,3)
Traceback (most recent call last):
File "<pyshell#27>", line 1, in <module>
c=C(2,3)
TypeError: C() takes no arguments
C.add()
Traceback (most recent call last):
File "<pyshell#28>", line 1, in <module>
C.add()
AttributeError: type object 'C' has no attribute 'add'
c.__dict__
mappingproxy({'__module__': '__main__', '__firstlineno__': 1, '_init_': <function c._init_ at 0x000002012D5AA0C0>, '__static_attributes__': ('x', 'y'), '__dict__': <attribute '__dict__' of 'c' objects>, '__weakref__': <attribute '__weakref__' of 'c' objects>, '__doc__': None})
c.add()
Traceback (most recent call last):
File "<pyshell#30>", line 1, in <module>
c.add()
AttributeError: type object 'c' has no attribute 'add' |
|