2016年9月18日 星期日

程式集訓 F010:溢出字元-beep

#coding=utf8

#程式集訓  F010:溢出字元-beep
'''
題目:(F010) 溢出字元-beep : 輸出相同的字串及聲音

Escape Sequence Meaning
\newline Ignored
\\ Backslash (\)
\' Single quote (')
\" Double quote (")
\a ASCII Bell (BEL)
\b ASCII Backspace (BS)
\f ASCII Formfeed (FF)
\n ASCII Linefeed (LF)
\r ASCII Carriage Return (CR)
\t ASCII Horizontal Tab (TAB)
\v ASCII Vertical Tab (VT)
\ooo ASCII character with octal value ooo
'''
#\xhh.... ASCII character with hex value hh....

#If you're on a Unix terminal, you can print "\a" to get a terminal bell:
def beep():
      print ("\a")

for i in range (0,10):
    beep()
#=======================================
import winsound         # for sound
import time             # for sleep

Freq = 2500 # Set Frequency To 2500 Hertz
Dur = 1000 # Set Duration To 1000 ms == 1 second
winsound.Beep(Freq,Dur)
time.sleep(0.25)        # in seconds (0.25 is 250ms)

winsound.Beep(440, 250) # frequency, duration
time.sleep(0.25)        # in seconds (0.25 is 250ms)

winsound.Beep(600, 250)
time.sleep(0.25)

沒有留言:

張貼留言

Messaging API作為替代方案

  LINE超好用功能要沒了!LINE Notify明年3月底終止服務,有什麼替代方案? LINE Notify將於2025年3月31日結束服務,官方建議改用Messaging API作為替代方案。 //CHANNEL_ACCESS_TOKEN = 'Messaging ...