解析时出现意外的EOF错误?

时间:2018-04-27 04:07:22

标签: python syntax-error bots eof discord

之前从未在python中编码,但刚刚开始,并且在创建不和谐机器人时遇到错误。不确定代码有什么问题,但它看起来不像是最后一行。

import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import time

Client = discord.client ()
bot_prefix = "!b"
client = commands.Bot (command_prefix=bot_prefix)

@client.event
async def on_ready () :
    print("With Bepis")     

@client.command(pass_context=true)
async def on_message(ctx:await client.say ("bepis")
                     if message.content == "bepis"
       @client.send_message (message.channel, "**BEPIS**")   

@client.run ("censored token")    
是的,我知道我的机器人会变得愚蠢。我只是用它作为更官方机器人的测试。帮助是非常感激的。

2 个答案:

答案 0 :(得分:1)

将最后一行更改为

client.run("censored token")

@指定一个函数装饰器,因此解析器很困惑,因为它后面没有任何内容。 https://www.python.org/dev/peps/pep-0318/

答案 1 :(得分:0)

您缺少(" bepis")旁边的括号。解析器在仍然试图找到关闭错误的右括号时会发现EOF。