<p>我有一个简短的代码片段,它不起作用,并不断给我这个错误:</p>
<p><img src="https://i.stack.imgur.com/xq4rs.png" alt="iMac-di-Luca:~ luca$ ./peasantlr.py | File "./peasantlr.py", line 24 | for char in data: | IndentationError: unindent does not match any outer indentation level"/></p>
<p>我在我的代码里没有发现任何错误。。。我已经检查过了,没有可能导致此错误的无效ASCII字符。你知道吗</p>
<pre><code>#!/usr/bin/env python
def posts(data):
postdata = ""
for char in data:
# If it's a non-escaped {, then it's the beginning of a post.
if char == "{":
insidepost = True
# Skip to the char after {, start copying from there
continue
# If it's a non-escaped }, yield the post, and clean the buffer.
if char == "}":
insidepost = False
yield postdata.replace("&lc;","{").replace("&rc;","}")
postdata = ""
# While in a post, copy the data into the post buffer.
if insidepost:
postdata += char
def findtags(data):
tagdata = ""
for char in data: *[This is the line which causes the error]*
if char == "[":
insidetag = True
continue
if char == "]":
insidetag = False
yield postdata
postdata = ""
if insidepost:
postdata += char
f = """{A}{B}{c}{dDD}"""
for f in posts(f): print f
</code></pre>
<p>有人知道怎么解决这个问题吗?非常感谢。你知道吗</p>