2015-04-16 72 views
0

我寫一個腳本在我的大學自動化HVZ遊戲和已經運行到這個奇怪的令人沮喪的語法錯誤:令人沮喪的Python語法錯誤

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's應該在哪裏在線的末尾,我不使用任何\ r的)

你可以找到我的這個項目here所有的代碼,如果你想嘗試自己運行它

回答

2

有上線不平衡(失蹤)括號以上行上調錯誤:

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

請注意,某些編輯器具有匹配的圓括號突出顯示,以及用於在匹配括號內來回移動的鍵組合。使用an editor with these features可以幫助減少這些錯誤。

+0

謝謝,有時我可能會有點白癡。我會盡快接受你的回答。 –

相關問題