Untitled
decorator `atualizar` that prints the start and end time of the `tempo` function execution, which simulates an update process by sleeping for a second. The snippet also shows how to apply the decorator both directly and through a commented-out alternative method.unknown
python
11 days ago
454 B
3
Indexable
Never
from datetime import datetime from time import sleep def atualizar(sistema): def horario_de_inicio(): print(datetime.now().strftime('%H:%M:%S')) sistema() print(datetime.now().strftime('%H:%M:%S')) return horario_de_inicio @atualizar # Primeiro modo def tempo(): print('Atualizando...') sleep(1) tempo() # Primeiro modo # pronto = atualizar(tempo) ## Segundo modo # pronto() ## Segundo modo
Leave a Comment