Luego de consultar expertos en la materia, programadores de varias áreas y maestros dimos con la respuesta al problema y la dejamos plasmada en esta publicación.
Ejemplo 1: python cómo hacer un cronómetro
import time
import sys
time_start = time.time()
seconds =0
minutes =0
running =Truewhile running:try:
sys.stdout.write("rminutes Minutes seconds Seconds".format(minutes=minutes, seconds=seconds))
sys.stdout.flush()
time.sleep(1)
seconds =int(time.time()- time_start)- minutes *60if seconds >=60:
minutes +=1
seconds =0except KeyboardInterrupt as e:
running =False
Ejemplo 2: hwo para crear un cronómetro usando Python
# Create a stopwatch# Import a module called as timeimport time
# create all the variables
day =0
hour =0min=0
sec =0# Display the headingsprint("D - H - M - S")print()# Create an infinite loopwhileTrue:# Create the main part of the stopwatch
time.sleep(1)if sec ==59:
sec =-1min=min+1
sec = sec +1ifmin==60:min=0
hour = hour +1if hour ==24:
hour =0
day = day +1print(day,"-", hour,"-",min,"-", sec)
Ejemplo 3: cronómetro de Python
1# latest_tutorial.py23import time
4from reader import feed
56defmain():7"""Print the latest tutorial from Real Python"""8 tic = time.perf_counter()9 tutorial = feed.get_article(0)10 toc = time.perf_counter()11print(f"Downloaded the tutorial in toc - tic:0.4f seconds")1213print(tutorial)1415if __name__ =="__main__":16 main()
Ejemplo 4: como hacer un cronómetro en pythoon
import time
now = time.time()
future = now +10while time.time()< future:# do stuffpass
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)