Python timer usage code

Source: Internet
Author: User

The Python timer has many problems during running. Let's take a look at how to solve these problems. I hope you will have some gains. The Code is as follows:

 

 
 
  1. #! /Usr/bin/ENV Python
  2. Import datetime
  3. Import sys
  4. Import threading
  5. From tkinter import *
  6. Minute = 60 * int (SYS. argv [1])
  7. Curtime = datetime. datetime. Now ()
  8. Print ("time:", curtime)
  9. Scrtime = curtime + datetime. timedelta (0, minute, 0)
  10. Print ("target time:", scrtime)
  11. Def wait ():
  12. Threading. _ sleep (minute)
  13. Def Stat ():
  14. Dsttime = datetime. datetime. Now ()
  15. TMP = dsttime-scrtime + scrtime
  16. Print ("current time:", TMP)
  17. If TMP = dsttime:
  18. Class app (FRAME ):
  19. Def _ init _ (self, Master = none ):
  20. Frame. _ init _ (self, Master)
  21. Self. Pack ()
  22. MyApp = app ()
  23. MyApp. master. Title ("time reached ")
  24. MyApp. master. maxsize (150,0)
  25. MyApp. mainloop ()
  26. Else:
  27. Print ("no ")
  28. Wait ()
  29. Stat ()

 

The above describes how to use the python timer.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.