• Python下课时间表:


    1. from datetime import datetime
    2. day_list = [
    3. '08:30-09:15',
    4. '09:15-09:25',
    5. '09:25-10:10',
    6. '10:10-10:20',
    7. '10:20-11:05',
    8. '11:05-11:15',
    9. '11:15-12:00',
    10. '12:00-13:50',
    11. '13:50-14:35',
    12. '14:35-14:45',
    13. '14:45-15:30',
    14. '15:30-15:40',
    15. '15:40-16:25',
    16. '16:25-16:35',
    17. '16:35-17:20',
    18. '17:20-18:30',
    19. '18:30-19:15',
    20. '19:15-19:25',
    21. '19:25-20:10',
    22. '20:10-20:20',
    23. '20:20-22:00',
    24. ]
    25. dictionaries = {
    26. '08:30-09:15': '【 上午第一节课上课 】',
    27. '09:15-09:25': '【 上午第一节课下课 】',
    28. '09:25-10:10': '【 上午第二节课上课 】',
    29. '10:10-10:20': '【 上午第二节课下课 】',
    30. '10:20-11:05': '【 上午第三节课上课 】',
    31. '11:05-11:15': '【 上午第三节课下课 】',
    32. '11:15-12:00': '【 上午第四节课上课 】',
    33. '12:00-13:50': '【 中午休息时间 】',
    34. '13:50-14:35': '【 下午第一节课上课 】',
    35. '14:35-14:45': '【 下午第一节课下课 】',
    36. '14:45-15:30': '【 下午第二节课上课 】',
    37. '15:30-15:40': '【 下午第二节课下课 】',
    38. '15:40-16:25': '【 下午第三节课上课 】',
    39. '16:25-16:35': '【 下午第三节课下课 】',
    40. '16:35-17:20': '【 下午第四节课上课 】',
    41. '17:20-18:30': '【 下午休息时间 】',
    42. '18:30-19:15': '【 晚上第一节课上课 】',
    43. '19:15-19:25': '【 晚上第一节课下课 】',
    44. '19:25-20:10': '【 晚上第二节课上课 】',
    45. '20:10-20:20': '【 晚上第二节课下课 】',
    46. '20:20-22:00': '【 晚上第三节课上课 】',
    47. }
    48. for i in day_list:
    49. begin_time = i[:5]
    50. end_time = i[-5:]
    51. # 开始时间
    52. begin = datetime.strptime(str(datetime.now().date()) + begin_time, "%Y-%m-%d%H:%M")
    53. # 结束时间
    54. end = datetime.strptime(str(datetime.now().date()) + end_time, "%Y-%m-%d%H:%M")
    55. # 当前时间
    56. now = datetime.now()
    57. if begin < now < end:
    58. s = dictionaries.get(i)
    59. x = datetime.strptime(str(datetime.now().date()) + str(end - now)[:4], "%Y-%m-%d%H:%M")
    60. a = int(datetime.strftime(x, '%M')) + 1
    61. if str(end - now)[:1] != '0':
    62. a = int(str(end - now)[:1]) * 60 + int(a)
    63. print('%s距离结束%s分钟' % (s, a))
    64. print(i)
    65. break
    66. else:
    67. continue

  • 相关阅读:
    Spring Security使用JSON格式登录
    一个简单算法解决集群定时任务重复执行
    浅析哈希源码
    Linux安装jdk1.8教程(服务器可以访问网络)
    微信小程序python+uniapp+hbuiderx宠物美容用品商城领养寄养系统i843n
    【web前端】css3(下)
    .NET 面向对象程序设计 —— 学习笔记 详细版
    勇敢的人先享受世界?
    IP组播基础
    Baumer工业相机堡盟工业相机如何通过NEOAPISDK实现根据每次触发信号移动感兴趣区域ROI(C#)
  • 原文地址:https://blog.csdn.net/Ben_boba/article/details/128044429