【发布时间】:2017-02-10 02:04:50
【问题描述】:
所以我试图在我的代码完成后播放一个简单的哔声,因为处理大量数据需要一段时间。我在网上尝试了其他示例,但似乎没有任何效果。我试过了:
import sys
sys.stdout.write('\a')
sys.stdout.flush()
它在 IDE shell 中输出单词 bel,但没有其他内容
我也试过了:
import os
print('\a')
输出完全相同的东西。
我试过了
import os
os.system('play --no-show-progress --null --channels 1 synth %s sine %f' % ( 4, 4))
简单的输出:
sh: play: command not found
有人有什么想法吗?
这里还有一个包含单词 bell 的 jpg。看起来很好笑...
我还确保我的音量已调高
更新:它可能只是我的 IDE。我尝试直接从终端启动 python 并使用 write('\a') 并且它有效。它只是在 101 翼不起作用
【问题讨论】:
-
sys.stdout.write('\a')对我有用,至少在 macOS Sierra 10.12.3 上