我想练习打字,但太无聊了 ,所以想做一个Python小脚本,使得我每打一个字,歌曲都会演奏3秒后暂停,使得我就象在演奏乐器一样,但是我做的这个脚本,虽然能播放音乐,但是不能达到要求
import time
import pygame
from pynput.keyboard import Key,Controller as key
import keyboard
pygame.mixer.init()
pygame.mixer.music.load("ウォルピスカーター - 晴天前夜.mp3")
pygame.mixer.music.play()
while(1):
event =pygame.event.get()
if event==keyboard.KEY_DOWN:
pygame.mixer.music.pause()
pygame.mixer.music.unpause()
time.sleep(3)
pygame.mixer.music.pause()