Python的扭曲问题
问题描述:
我有一个问题让我扭曲的脚本来运行其上线13Python的扭曲问题
File "sponzyTwisted.py", line 13
else:
^
SyntaxError: invalid syntax
这里抛出一个语法错误,是因为我使用它的代码:
class printStuffs(object):
count = 0
def count(self):
count += 1
print "the counter is at" + count
class controlListener(object):
count = 0
def count(selt):
if self.counter == 0:
print "Killing Process"
reactor.stop()
else:
print self.counter, '...'
self.counter -= 1
reactor.callLater(1, self.count)
from twisted.internet import reactor
print "Printing random stuff"
reactor.callWhenRunning(printStuffs().count)
print "Intializing kill listner"
reactor.callWhenRunning(controlListner().count)
我从字面上切割和粘贴这里的代码: http://krondo.com/our-eye-beams-begin-to-twist/
所以我不认为这个错误是由于缩进。谢谢阅读!
答
如果这是您的实际缩进,那么您的缩进是关闭的。
你的陈述不在函数的范围内。
你明白了,我必须检查他们5次,但我又做了,它的工作? –
很高兴现在正在工作。你应该重新命名一些你的变量,然后在'def count(selt)'我认为你的意思是'def count(self)' – Pythonista
是的,我注意到刚才有另一个错误哦,那就是编码 –