Discord Python 我的代码有什么问题?

Discord Python whats wrong with my code?

我的代码已关闭,我在 args

上收到错误 'SyntaxError: invalid syntax'
   @client.command(pass_context=True)
   async def render(*args, message):
      """Renders A Growtopia World"""
      mesg = ' '.join(args)
      await client.say(":earth_americas: World Render:")
      return await client.say('https://www.growtopiagame.com/worlds/'mesg'.png')

*args, **kwargs 总是出现在参数的末尾。

async def render(message, *args):
    ...

正确。

确定这不是最后一行 'mesg' 的语法错误?因为那不是在 Python.

中连接字符串的方式

有很多方法可以格式化或连接字符串(最明显的方法就是像这样添加它们:string_sum = string1 + string2),但我个人最喜欢在与变量等组合时进行字符串格式化,如果在 Python 3.6+,是 f 弦 (https://cito.github.io/blog/f-strings/)。

所以在这种情况下你会做 client.say(f'https://www.growtopiagame.com/worlds/{mesg}.png')

(P-EDIT: Godron 有点正确,这取决于 Python 是 2 还是 3。有关详细信息,请参阅此 SO 答案 )