demo.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # -*- coding: utf-8 -*-
  2. # @Author: wangkun
  3. # @Time: 2022/3/31
  4. from datetime import date, timedelta
  5. import datetime
  6. import time
  7. class Demo:
  8. @classmethod
  9. def demo1(cls):
  10. download_video_resolution = "720*1280"
  11. download_video_width = download_video_resolution.split("*")[0]
  12. download_video_height = download_video_resolution.split("*")[-1]
  13. print(download_video_resolution)
  14. print(download_video_width)
  15. print(download_video_height)
  16. @classmethod
  17. def time(cls):
  18. # 推荐
  19. time1 = int(time.time() * 1000)
  20. print(time1)
  21. # 不推荐
  22. time2 = round(time.time()) * 1000
  23. print(time2)
  24. # 统一获取当前时间
  25. now = datetime.datetime.now()
  26. print(type(now))
  27. print(f"now:{now}")
  28. # 昨天
  29. yesterday = (date.today() + timedelta(days=-1)).strftime("%Y-%m-%d")
  30. print(type(yesterday))
  31. print(f"昨天:{yesterday}")
  32. # 今天
  33. today = date.today()
  34. print(type(today))
  35. print(f"今天:{today}")
  36. # 明天
  37. tomorrow = (date.today() + timedelta(days=1)).strftime("%Y-%m-%d")
  38. print(type(tomorrow))
  39. print(f"明天:{tomorrow}")
  40. @classmethod
  41. def demo2(cls):
  42. s = "0"
  43. print(int(int(s) / 10))
  44. if __name__ == "__main__":
  45. demo = Demo()
  46. # demo.demo1()
  47. demo.time()
  48. pass