0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Pythonで学校のチャイムを作成する

Posted at

はじめに

怒らないから在宅勤務でさぼってるやつ集まれ。
あの日を思い出せ!数分置きにチャイムを鳴らしてやるよ。

コード

import time
import datetime
import winsound # Windowsさん
import os # Macさん

def paly_chime():
    # windowsさん
    winsound.Beep(440, 1000)

    # Macさん
    #os.system('say "Chime"')

# スケジュールの設定(指定した時間にチャイムが鳴る)
schedule = [
    (9, 0), (10, 30), (10, 40), (12, 0),
    (13, 0), (14, 30), (14, 40), (16, 0),
    (16, 10), (17, 0), (17, 10), (18, 0)
]

while True:
    now = datetime.datetime.now()
    current_time = (now.hour, now.minute)

    if current_time in schedule:
        play_chime()
        time.sleep(60)

    time.sleep(1)

Macのsay "Chime"かっこよくね。ずる。

おわりに

仕事しろ。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?