令人沮丧的 python 语法错误

Frustrating python syntax error

我正在写一个脚本来在我的大学里自动化 HvZ 游戏,并且 运行 遇到了这个奇怪的令人沮丧的语法错误:

  File "HvZGameMaster.py", line 53
class players(object):
    ^
SyntaxError: invalid syntax

这是有问题的代码

class mailMan(object):
    """mailMan manages player interactions such as tags reported via text messages or emails"""
    def __init__(self, playerManager):
        super(mailMan, self).__init__()
        self.mail = imaplib.IMAP4_SSL('imap.gmail.com')
        self.mail.login(args.username,args.password)
        self.mail.list()
        # Out: list of "folders" aka labels in gmail.
        self.mail.select("inbox") #connect to inbox.

    def getBody(self, emailMessage):
        maintype = emailMessage.get_content_maintype()
        if maintype == 'multipart':
            for part in emailMessage.get_payload():
                if part.get_content_maintype() == 'text':
                    return part.get_payload()
        elif maintype == 'text':
            return emailMessage.get_payload()

    def getUnread(self):
        self.mail.select("inbox") # Select inbox or default namespace
        (retcode, messages) = self.mail.search(None, '(UNSEEN)')
        if retcode == 'OK':
            retlist = []
            for num in messages[0].split(' '):
                print 'Processing :', messages
                typ, data = self.mail.fetch(num,'(RFC822)')
                msg = email.message_from_string(data[0][1])
                typ, data = self.mail.store(num,'-FLAGS','\Seen')
                if retcode == 'OK':
                    for item in str(msg).split('\n'):
                        #finds who sent the message
                        if re.match("From: *",item):
                            print (item[6:], self.getBody(msg))
                            retlist.append((item[6:], self.getBody(msg).rstrip())
                            #print (item, self.getBody(msg).rstrip())


class players(object): #<-the problem happens here
    """manages the player"""
    def __init__(self, pDict):
        super(players, self).__init__()
        self.pDict = pDict
    #makes a partucular player a zombie
    def makeZombie(self, pID):
        self.pDict[pID].zombie = True
    #makes a partucular player a zombie
    def makeHuman(self, pID):
        self.pDict[pID].zombie = False

据我所知,我所写的内容是正确的,并且我已经检查以确保它都是制表符而不是空格我已经确保我没有任何错误的 \r 或 \n 浮动(所有 \n 都应该在行尾,我没有使用任何 \r's)

如果您想自己尝试运行,您可以找到这个项目的所有代码here

引发错误的行上方行中存在不平衡(缺失)括号:

retlist.append((item[6:], self.getBody(msg).rstrip())

请注意,某些编辑器会突出显示匹配的括号,以及用于在匹配的括号之间来回移动的组合键。使用 an editor with these features 可以帮助减少这些错误。