Play simple beep with python without external library

后端 未结 3 1688
不思量自难忘°
不思量自难忘° 2020-12-13 14:33

Using only the modules that come with a standard python 2.6 installation, would it be possible to play a simple beeping noise?

3条回答
  •  一整个雨季
    2020-12-13 15:07

    If you're on a Unix terminal, you can print "\a" to get a terminal bell:

    >>> def beep():
    ...     print "\a"
    >>> beep()
    

    Of course, that will print a newline too… So sys.stdout.write("\a") might be better. But you get the idea.

提交回复
热议问题