代码:
import pygame
pygame.mixer.init()
audio_clip=pygame.mixer.Sound("10 明年今日.ogg")
channel=pygame.mixer.find_channel(True)
channel.play(audio_clip)
print(audio_clip.get_length)
结果:
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
== RESTART: C:\Users\Administrator\Desktop\Sandstorm Music\Sandstorm Music.py ==
pygame 2.1.2 (SDL 2.0.18, Python 3.8.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
<built-in method get_length of Sound object at 0x0261D1B8>
想直接要秒数怎么办?
get_length 是方法吧 你改成get_length()
print(audio_clip.get_length())
最右边加一对小括号试试?