有人知道如何使用30.0更改此矩形的所有边吗?
我尝试了此操作,但结果为“无”:
class Rectangle:
def __init__(self, height=50.0, width=40.0, color="white"):
self.height = height
self.width = width
self.color = color
def area_calculation(self):
return self.height * self.width
def change_square(self, side):
self.height = side
self.width = side
if __name__ == "__main__":
NewRectangle = Rectangle()
a=NewRectangle.change_square(30.0)
print(a)
感谢您的帮助