假设你想把它放在命令中,@bot.command(name='del')@commands.is_owner #only bot owner can use thisfor folder in os.listdir('./foldermp3filesarestored'): if folder.endswith('.mp3'): os.remove(folder) else: print("found file not ending in .mp3")你也可以把它放在 on_ready 的 for 循环中。