pygame.init()
pygame.display.init
screen = pygame.display.set_mode([800, 600])
test = "space.ogg"
pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)
pygame.mixer.music.load(path.join(snd_dir, 'space.ogg'))
pygame.mixer.music.play(test)
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("My Game")
clock = pygame.time.Clock()
当我尝试运行代码时出现错误
错误: pygame.mixer.music.play(test( 类型错误:需要整数(获得类型str(
play
接受两个参数,loops
和start
,它们都默认为0。没有字符串 - 所以你给了错误的参数。
你传递到播放方法一个字符串(空格.ogg(,这是错误
进一步查看Google结果,您会看到一个SO问题:pygame。