我想知道如何在一段时间后不使用sleep
函数来播放.wav
文件。实际上,我想知道是否有一种方法可以在Python中跟踪时间,这样,在15秒之后,我就可以在不暂停代码的情况下播放一个声音。
# checks if I should play the sound or not and, sets the variable
def Tyler(self):
if self.started == 1:
if self.isTaiwan == 0:
if self.myListNames[self.current_player_id / 3].lower() == "tyler":
self.isTyler = 1
else:
self.isTyler = 0
self.Tyler()
if self.isTyler == 1:
time.sleep(6)
winsound.PlaySound("tyler.wav", winsound.SND_ASYNC)
# This is where I would want to check to see
# if some time has passed and the conditions haven't changed.
目前没有回答
相关问题 更多 >
编程相关推荐