Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python SyntaxError:位置参数跟在关键字参数[discord.py]后面_Python_Python 3.x_Discord.py_Discord.py Rewrite - Fatal编程技术网

Python SyntaxError:位置参数跟在关键字参数[discord.py]后面

Python SyntaxError:位置参数跟在关键字参数[discord.py]后面,python,python-3.x,discord.py,discord.py-rewrite,Python,Python 3.x,Discord.py,Discord.py Rewrite,这是我的代码: async def tracklooper(ctx, timesPlayedTrack): voice = get(bot.voice_clients, guild=ctx.guild) if (timesPlayedTrack <= totaltime): if voice and voice.is_playing(): voice.stop() print(str(timesPlayedTr

这是我的代码:

async def tracklooper(ctx, timesPlayedTrack):
    voice = get(bot.voice_clients, guild=ctx.guild)
    if (timesPlayedTrack <= totaltime):
        if voice and voice.is_playing():
            voice.stop()
            print(str(timesPlayedTrack))
            run_coroutine_threadsafe(msg.edit(content="Playing "+vTT+" for "+str(timesPlayedTrack)+" time/s"), bot.loop)
            voice.play(discord.FFmpegPCMAudio(audio), after=lambda e: asyncio.run_coroutine_threadsafe(tracklooper(ctx, timesPlayedTrack+1)), bot.loop)
            voice.is_playing()
    else:
        run_coroutine_threadsafe(msg.delete(), bot.loop)
        run_coroutine_threadsafe(ctx.send("Finished playing "+vTT+" for "+str(totaltime)+" times"), bot.loop)
        run_coroutine_threadsafe(looptrack_set_times.delete(), bot.loop)
        run_coroutine_threadsafe(ply.delete(), bot.loop)

我对python语言不太熟悉,因此在查找修复程序时遇到困难。

关键字参数,在您的例子中,
after=lambda…
,应该始终放在函数调用的末尾。您已将
bot.loop
放在末尾,它不是关键字参数


查看API文档,
VoiceClient.play
的唯一参数是
源代码和
后的
,因此您应该删除
bot.loop
,因为您已经提供了这两个参数。

这是否回答了您的问题?
voice.play(discord.FFmpegPCMAudio(audio), after=lambda e: asyncio.run_coroutine_threadsafe(tracklooper(ctx, timesPlayedTrack+1)), bot.loop)
                                                                                                                                      ^
SyntaxError: positional argument follows keyword argument