我想在此代码上添加一个计数器,以便每次打印ligma字时,它都会计算一次在屏幕上打印ligma的次数
import winsound
import time
from threading import Thread
def play_sound():
for _ in range(10):
winsound.PlaySound("dank", winsound.SND_ALIAS)
time.sleep(2.5)
thread = Thread(target=play_sound)
thread.start()
while True:
print ('ligma')
time.sleep(1.5)
答案 0 :(得分:1)
count = 0
while True:
print ('ligma')
count += 1
time.sleep(1.5)