我正在尝试编写我的第一个 python 脚本。这是可行的,但经过一些轻微的重构,我显然打破了缩进。我无法确定是什么问题。解释器抱怨以下方法。有人可以指出吗?
def dataReceived(self, data):
a = data.split(':')
print a
if len(a) > 1:
command = a[0]
content = a[1]
msg = ""
if command == "iam":
self.name = content
msg = self.name + " has joined"
elif command == "msg":
msg = self.name + ": " + content
print msg
错误显示:文件“python_server.py”,第 17 行 a = data.split(':') ^ IndentationError: expected an indented block