python pygame播放音频文件

python pygame播放音频文件

 

pip install pygame

 

 

import pygame

# Initialize pygame
pygame.init()

# Load the MP3 file
pygame.mixer.music.load("1.mp3")

# Play the MP3 file
pygame.mixer.music.play()

# Wait for the MP3 file to finish playing
while pygame.mixer.music.get_busy():
    pygame.time.Clock().tick(10)

# Clean up
pygame.quit()

 

 

 

########################

posted @ 2023-04-01 19:14  西北逍遥  阅读(45)  评论(0编辑  收藏  举报