我们的讲师给了我们一些代码来帮助我们完成作业,当我试图运行它时,我得到了一个语法错误。我根本没有接触过代码,它的意思是运行时不需要我们做任何更改。这是我们得到的一半代码:class Flusher(MessageProc):
def main(self):
super().main()
print('before start message')
self.receive(
Message(
'start',
action=self.flush))
print('after start message')
self.receive(
Message(
ANY,
action=lambda data:print('The first thing in the queue after the flush is', data)))
def flush(self, *args):
self.receive(
Message(
ANY,
action=self.flush), # recursively call the flush method
TimeOut(
0,
action=lambda: None)) # when no more messages return
引发异常的行是:
^{pr2}$
这是我第一次使用Python,所以请有人解释一下出了什么问题,以及我应该怎么解决它。在
编辑:错误跟踪是:File "./demo_timeout.py", line 18
action=lambda data:print('The first thing in the queue after the flush is' + data)))
^
SyntaxError: invalid syntax