从Python中访问Class中的变量

时间:2017-02-07 17:47:26

标签: python variables

如何在class EchoBot之外打印讯息? 问题是,每当我尝试在课外打印消息时,它都不会显示或仅显示错误消息未定义。

import fbchat

class EchoBot(fbchat.Client):
    def __init__(self,email, password, debug=True, user_agent=None):
        fbchat.Client.__init__(self,email, password, debug, user_agent)

    def on_message(self, mid, author_id, author_name, message, metadata):
        self.markAsDelivered(author_id, mid) #mark delivered
        self.markAsRead(author_id)#mark read



        print("%s said: %s"%(author_id, message))


        if str(author_id) != str(self.uid):
            self.send(author_id,message)



bot = EchoBot("ID", "PASSWORD")
bot.listen()

0 个答案:

没有答案