Python: comanda de somn - explicat simplu
Comanda de somn în Python este extrem de practică. Face ca un program să aștepte puțin timp înainte de a executa alte comenzi. Aici vă explicăm cum să utilizați exact comanda de somn.
Python: Utilizați comanda sleep
Puteți adăuga cu ușurință comanda de repaus la codul programului dvs.:
- Adăugați linia „din timp importați somnul” (fără ghilimele) la începutul codului dvs. pentru a putea utiliza funcția de repaus ulterior.
- Acum puteți adăuga comanda "sleep (1)" oriunde în cod.
- Între paranteze trebuie să scrieți timpul în câteva secunde pe care programul trebuie să îl aștepte.
- În acest caz, programul așteaptă exact o secundă.
Mai multe sfaturi despre Python în ghidurile noastre CHIP
Sfat: Pe pagina noastră de subiect din limbajul de programare Python veți găsi și alte tutoriale despre programare. Acolo vă vom arăta, de exemplu, cum puteți converti un număr întreg într-un șir.