我的代码运行时间非常长,我不想一直盯着它看,而是想知道它什么时候完成。
我在考虑让它在到达代码末尾时播放一个.wav文件.
如果是的话,我怎样才能做到呢?
发布于 2018-03-01 16:25:51
import winsound
duration = 1000 # millisecond
freq = 440 # Hz
winsound.Beep(freq, duration)其中,FREQ是频率(以赫兹为单位),而持续时间是毫秒(毫秒)。
import os
duration = 1 # second
freq = 440 # Hz
os.system('play --no-show-progress --null --channels 1 synth %s sine %f' % (duration, freq))要使用此示例,必须安装sox...
在Debian/Ubuntu/LinuxMint上,您需要在终端中运行:
sudo apt install sox这是Macport的方法...运行这是您的终端:
sudo port install sox如果你在终端上使用Mac,也许在Windows上也能做同样的事情,但我只知道Mac的情况:
import os
os.system('say "your program has finished"')import os
os.system('spd-say "your program has finished"')您需要安装speech-dispatcherUbuntu中的包(或其他发行版上的相应包):
sudo apt install speech-dispatcher发布于 2018-03-01 17:11:16
def beep():
print "\a"
beep()在Windows中,可以在末尾放:
import winsound
winsound.Beep(500,1000)
where 500 is the frequency in Herz
1000 is the duration in milisecondshttps://stackoverflow.com/questions/-100004182
复制相似问题