在 Python 中,装饰器是通过函数来实现的。下面是一些常见的 Python 装饰器的写法示例: 1. 最基本的装饰器写法: def my_decorator(func): def wrapper(): print("Something is happening before the function is called.") func() print(