3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Python でけたたましくアラート音を鳴らしまくる

Posted at

目的

バッチ処理が完了した際や,常駐型プログラムの異常検知時など,注意を引きたいときにアラート音を鳴らしまくりたい

1回だけ音を鳴らす

print('\a')

連続で音を鳴らす

import sys
import time

for _ in range(10):
    sys.stdout.write('\a')
    sys.stdout.flush()
    time.sleep(0.15)

鳴らす回数,スリープ間隔はお好みで.

なぜこんなややこしいのか

print('\a' * 10)

ではいかんのか?
-> いかんのです.

バッファにまとめて標準出力される都合上,全ての音がまとめて一回だけ鳴ります.
面倒でも1回ずつ書き込み&出力すれば連続で音が鳴りまくります.

3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?