一个简单的Python面向对象编程实例是创建一个表示矩形的类,具有计算面积和周长的方法。
```python
class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
def area(self):
return self.width * self.height
def perimeter(self):
return 2 * (self.width + self.height)
# 创建一个矩形对象
rect = Rectangle(3, 4)
# 计算矩形的面积和周长
print("矩形的面积:", rect.area())
print("矩形的周长:", rect.perimeter())
```