python
def print_fin(func):
def wrapper(*args, **kwargs):
output = func(*args, **kwargs)
print(f'FIN {func.__name__}')
return output
return wrapper
Comment utiliser:
python
@print_fin
def greet():
print('Hello!')
greet()
résultat
Hello!
FIN greet
Référence: [About Python decorators --Qiita](https://qiita.com/mtb_beta/items/d257519b018b8cd0cc2e#%E3%81%A4%E3%81%BE%E3%82%8A%E3%83%87% E3% 82% B3% E3% 83% AC% E3% 83% BC% E3% 82% BF% E3% 81% A7% E4% BD% 95% E3% 81% 8C% E3% 81% A7% E3% 81% 8D% E3% 82% 8B% E3% 81% AE% E3% 81% 8B)
Recommended Posts