Python: comando sleep - spiegato semplicemente
Il comando sleep in Python è estremamente pratico. Fa sì che un programma attenda brevemente prima di eseguire ulteriori comandi. Qui spieghiamo come usare esattamente il comando sleep.
Python: usa il comando sleep
È possibile aggiungere facilmente il comando sleep al codice del programma:
- Aggiungi la riga "from time import sleep" (senza virgolette) all'inizio del codice in modo da poter utilizzare la funzione sleep in un secondo momento.
- Ora puoi aggiungere il comando "sleep (1)" in qualsiasi punto del codice.
- Tra parentesi devi scrivere il tempo in secondi che il programma dovrebbe attendere.
- In questo caso, il programma attende esattamente un secondo.
Ulteriori suggerimenti su Python nelle nostre guide CHIP
Suggerimento: puoi trovare altri tutorial di programmazione sulla nostra pagina degli argomenti del linguaggio di programmazione Python. Lì ti mostreremo, ad esempio, come puoi convertire un numero intero in una stringa.