Creating a timer in python

后端 未结 13 2217
孤独总比滥情好
孤独总比滥情好 2020-12-07 18:58
import time
def timer():
   now = time.localtime(time.time())
   return now[5]


run = raw_input(\"Start? > \")
while run == \"start\":
   minutes = 0
   current_         


        
13条回答
  •  长情又很酷
    2020-12-07 19:41

    You can really simplify this whole program by using time.sleep:

    import time
    run = raw_input("Start? > ")
    mins = 0
    # Only run if the user types in "start"
    if run == "start":
        # Loop until we reach 20 minutes running
        while mins != 20:
            print(">>>>>>>>>>>>>>>>>>>>> {}".format(mins))
            # Sleep for a minute
            time.sleep(60)
            # Increment the minute total
            mins += 1
        # Bring up the dialog box here
    

提交回复
热议问题