def test(): i=0 ''' aaaaaa ''' while i < 5: ''' bbbbbb ''' print(i) i+=1 if __name__ == '__main__': test()
如上,Python注释的缩进不得当,也会导致IndentationError: unexpected indent。将注释的缩略修改如下后解决。
def test(): i=0 ''' aaaaaa ''' while i < 5: ''' bbbbbb ''' print(i) i+=1 if __name__ == '__main__': test()