Home Backend Development Python Tutorial pygame播放音乐的方法

pygame播放音乐的方法

Jun 10, 2016 pm 03:12 PM
pygame

本文实例讲述了pygame播放音乐的方法。分享给大家供大家参考。具体如下:

方法一:

import pygame
filename='/home/A.mp3'
pygame.mixer.music.load(filename)
pygame.mixer.music.play(loops=0, start=0.0)
Copy after login

方法二:

import pygame
filename='/home/pengtao/Music/b.mp3'
pygame.mixer.init()
pygame.mixer.music.load(filename)
pygame.mixer.music.play(1)

Copy after login

希望本文所述对大家的Python程序设计有所帮助。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Pygame installation details: teach you step by step to install and configure the development environment Pygame installation details: teach you step by step to install and configure the development environment Feb 20, 2024 pm 04:54 PM

Pygame installation details: teach you step by step to install and configure the development environment

How to install pygame How to install pygame Nov 27, 2023 pm 03:49 PM

How to install pygame

Getting Started with Pygame: Comprehensive Installation and Configuration Tutorial Getting Started with Pygame: Comprehensive Installation and Configuration Tutorial Feb 19, 2024 pm 10:10 PM

Getting Started with Pygame: Comprehensive Installation and Configuration Tutorial

Basic tutorial for learning Pygame: Quick introduction to game development Basic tutorial for learning Pygame: Quick introduction to game development Feb 19, 2024 am 08:51 AM

Basic tutorial for learning Pygame: Quick introduction to game development

Python's Pygame Font module - how to use text and fonts? Python's Pygame Font module - how to use text and fonts? Apr 23, 2023 pm 11:19 PM

Python's Pygame Font module - how to use text and fonts?

How to use Pygame's Draw drawing method in Python How to use Pygame's Draw drawing method in Python Apr 19, 2023 pm 04:46 PM

How to use Pygame's Draw drawing method in Python

How to create a simple word game using Python and Pygame How to create a simple word game using Python and Pygame May 09, 2023 pm 07:43 PM

How to create a simple word game using Python and Pygame

Pygame Installation Guide: An easy-to-understand introductory tutorial Pygame Installation Guide: An easy-to-understand introductory tutorial Feb 20, 2024 pm 12:39 PM

Pygame Installation Guide: An easy-to-understand introductory tutorial

See all articles