开发者

python 3 IRC bot syntax error

Okay, first off. I'm very new to python, and I've just started to teach myself python 3 As a fun project to help me learn I decieded to do an IRC Bot, I figured I'll follow a basic tutorial on creating a basic bot, and as I learn I could add more to it, and make it my own but the problem is I believe the tutorial was written for python 2.x. I've gotten a few errors that I was able to fix on my own, but now I'm getting this syntax error that I cant seem to figure out. the error is on line 39, here are lines 38 and 39, (38 because I had a syntax error there but managed to fix it)

if 开发者_开发知识库msgpart[0]=='`' and sender[0]==OWNER  # Treat all messages start with ` as a command
   cmd=msgpart[1:].split('')

and the error I get is.

File "pybot.py", line 39
cmd=msgpart[1:].split('')
  ^
Syntax error: invalid syntax

the error on line 38 was kind of the same thing, but with that I removed the : after owner and it fixed itself, which seemed weird to me because from what I understand theres supposed to be : after IF statements.


You are missing : after if statement. Should be:

if msgpart[0]=='`' and sender[0]==OWNER:
   cmd=msgpart[1:].split('')


You are missing a colon : at the end of the if statement:

if msgpart[0]=='`' and sender[0]==OWNER  # Treat all messages start with ` as a command
                                       ^

should be:

if msgpart[0]=='`' and sender[0]==OWNER:  # Treat all messages start with ` as a command
                                       ^


Check that your tabs and spaces are consistent in the source file. There seem to be 3 spaces in front of line 39 (normally it's 4, or at least some even number).

Plus the colon : at line 38 like others said.

The empty string in split('') is no syntax error, but it also looks weird. What are you trying to achieve there?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜