你好,我想用yowsup发送一条消息,但没有成功,你能帮我弄到IndentationError吗?
从yowsup.layers.interface导入YowInterfaceLayer,从yowsup.layers.protocol_messages.protocolentities导入ProtocolEntityCallback从yowsup.common.tools导入TextMessageProtocolEntity
EchoLayer类(YowInterfaceLayer):
@ProtocolEntityCallback("message")
def onMessage(self, messageProtocolEntity):
if messageProtocolEntity.getType() == 'text':
self.onTextMessage(messageProtocolEntity)
reply = 1
messageEntity = TextMessageProtocolEntity(reply,to = messageProtocolEntity.getFrom())self.toLower(messageEntity)
self.toLower(messageProtocolEntity.forward(messageProtocolEntity.getFrom()))
self.toLower(messageProtocolEntity.ack())
self.toLower(messageProtocolEntity.ack(True))
@ProtocolEntityCallback("receipt")
def onReceipt(self, entity):
self.toLower(entity.ack())
def onTextMessage(self,messageProtocolEntity):
# just print info
print("Echoing %s to %s" % (messageProtocolEntity.getBody(), messageProtocolEntity.getFrom(False)))发布于 2017-05-10 02:30:39
IndentationError:意外缩进
这是每个巨人都遇到过的常见问题。你的代码有一些额外的空格,或者任何制表符都是used.so的,基本上你必须检查每一行,手动删除多余的空格(快捷方式),并将它们替换为空格实例。
发布于 2017-05-10 03:04:50
Unexpected indent错误消息将始终告诉您在哪条线路上检测到问题。
在您的例子中,这显然是由于if和reply行不匹配所致。
https://stackoverflow.com/questions/42621833
复制相似问题