“def listen(self,phrase = None):”蟒蛇中的恐怖

时间:2017-11-06 08:50:27

标签: python bots telegram

我试图制作Telegram机器人并且在Chatbot代码中我每次运行时都会遇到这个问题“Unindent与任何外部缩进级别都不匹配”我仍然不知道如何解决它,我已经尝试更改符号和任何东西

import json
import subprocess as s

class Chatbot():
    def __init__(self, name):
        try:
            memory = open(name+'.json','r')
        except FileNotFoundError:
            memory = open(name+'.json','w')
            memory.write('["Will","Alfredo"]')
            memory.close()
            memory = open(name+'.json','r')
        self.name = name
        self.known = json.load(memory)
        memory.close()
        self.historico = []
        self.phrases = {'hello': 'hello, my name is GiroBot','goodbye':'bye, see you next time!'}

     def listening(self,phrases=None):
         if phrases == None:
             phrases = input('>: ')
         phrases = str(phrases)
         phrases = phrases.lower()
         phrases = phrases.replace('e','eh')
         return phrases

     def thinking(self,phrases):
         if phrases in self.phrases:
             return self.phrases[phrases]
         if phrases == 'learn':
             key = input('Digite a phrases: ')
             resp = input('Digite a response: ')
             self.phrases[key] = resp

这是代码,我对此有问题

 def listening(self,phrases=None): 
                                  ^

我在哪里得到Unindent与任何外部缩进级别都不匹配,请帮助

0 个答案:

没有答案