<p>我有以下pygame代码,但它通常适用于python</p>
<pre><code>expl_sounds = []
for snd in ['expl3.wav', 'expl6.wav']:
expl_sounds.append(pygame.mixer.Sound(path.join(snd_dir, snd)))
</code></pre>
<p>我想单独禁用列表中的所有项,而不是禁用整个应用程序或混合器。我尝试了以下方法:</p>
<pre><code> for i in expl_sounds:
expl_sounds[i].set_volume(Sound_Volume)
TypeError: list indices must be integers or slices, not Sound
</code></pre>
<p>我没有收到错误信息。循环中的i是一个整数,mixer.set_Volume是元素的有效操作</p>
<p>迭代并将卷应用于每个元素的正确方法是什么</p>