|
#!/usr/bin/python
# -*- coding: UTF-8 -*-
class Box:
def __init__(self):
self.length = 0
self.width = 0
self.height = 0
self.__volumn = (self.length)*(self.width)*(self.height)
def length(self,length):
print('length:',length)
self.length = length
def width(self,width):
print('width:',width)
self.length = width
def height(self,height):
print('height:',height)
self.height = height
def info(self):
print('length:',self.length,'width:',self.width,'height:',self.height,'Volumn is:',self.__volumn)
if __name__ == '__main__':
a = Box()
a.length(3)
a.width(4)
a.height(5)
a.info()
上面程序运行结束后,报错:
Traceback (most recent call last):
File "D:/SW/Python/program-defined/40_class.py", line 27, in <module>
a.length(3)
TypeError: 'int' object is not callable
|
|