반응형 [python3.10 기본] 18. 고급 함수 18.1 데코레이터데코레이터는 함수를 인자로 받아, 그 함수에 새로운 기능을 추가한 후 반환하는 함수입니다. 데코레이터를 사용하면 코드의 반복을 줄이고, 함수의 동작을 변경할 수 있습니다. 기본 데코레이터def my_decorator(func): def wrapper(): print("Something is happening before the function is called.") func() print("Something is happening after the function is called.") return wrapper@my_decoratordef say_hello(): print("Hello!")say_hello()인자를 받는 데코레이터d.. 2024. 7. 2. 이전 1 다음 반응형