程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Write an alarm clock in Python that makes you regret not getting up

編輯:Python

Hey, let's not mention that I've been lazy since I got home. I've always been disliked by others, and I still feel that there is no hope in life. Fortunately, I met some big guys in the community, which made me want to start over and be myself again.Joker, so I wanted to use something to remind me not to sleep in, and this article was born.

Alarm

poetry add playsoundpoetry add pyttsx3

If you are not familiar with playsound and pyttsx3, you can learn it. One is the audio playback module and the other is the text reading module. We will use it later.

First of all, let's set the scheduled time of the alarm clock:

alarm_time = input("Enter the alarm time to be set: HH:MM:SS\n")alarm_period=input("Please input the period to be set (AM or PM):\n")alarm_hour=alarm_time[0:2]#Get the houralarm_minute=alarm_time[3:5]#Get minutesalarm_seconds=alarm_time[6:8]#How many secondsalarm_period = alarm_period.upper()print("The setup is running successfully, I wish you a good rest....zzZZ..")

An alarm clock that can help you quit your job:

while flag:now = datetime.now()current_hour = now.strftime("%I")current_minute = now.strftime(&

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved