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)

沒有留言:

張貼留言

Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3

  Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3 AngularJS 實例 <!DOCTYPE html> <html> <head> <meta charse...