import os
import time
import random
i=1
while i<=7:
i=random.randint(1,7)
fname="d:/demo/notes/" +str(i)+".wav"
os.system(fname)
time.sleep(1/random.randint(1,2))
这里主要是猜测音阶对不对,跟菜数字没区别!
import os
import time
import random
note=random.randint(1,7)
fname="d:/demo/notes/" +str(note)+".wav"
while 1==1:
os.system(fname)
guess=int(input("请问你刚才听到的是C大调哪个音阶(1-7)?"))
continue
if guess>note:
print("高了")
elif guess<note:
print("低了")
else:
print("正确")
break