Python的一行未缩进代码被称为函数



在我正在开发的一个不和谐机器人程序中,我有一个读取

的函数
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith(';hello'):
await message.channel.send('Hello dirtbag')
if message.content.startswith(';bitcoin price'):
answer = bitcoin_price()ON
await message.channel.send("The current price of bitcoin is ' + answer + ' USD')

下面是

client.run(TOKEN)

但是底线不起作用,我的编辑器(虚拟工作室代码)显示它在on_message函数中,即使它是未缩进的。我还尝试在函数末尾添加passreturn,但它仍然不起作用。

检查这一行替换"用">

await message.channel.send("The current price of bitcoin is ' + answer + ' USD')

await message.channel.send('The current price of bitcoin is ' + answer + ' USD')

最新更新