Dav*_*ver 31
如果你在Unix终端上,你可以打印"\ a"来获得终端铃:
>>> def beep():
...     print "\a"
>>> beep()
当然,这也将打印换行...所以sys.stdout.write("\a")可能会更好.但是你明白了.
use*_*963 16
在Windows上:
import winsound         # for sound  
import time             # for sleep
winsound.Beep(440, 250) # frequency, duration
time.sleep(0.25)        # in seconds (0.25 is 250ms)
winsound.Beep(600, 250)
time.sleep(0.25)
34.4.winsound - Windows的声音播放界面:
http://docs.python.org/2.6/search.html?q=sound&check_keywords=yes&area=default
另请参阅:清除各种平台的屏幕和蜂鸣声.(Python食谱) http://code.activestate.com/recipes/577588-clear-screen-and-beep-for-various-platforms/