我有这个简短的代码片段,它不起作用,并不断给我这个错误:
我真的没有在我的代码中发现任何错误......我已经检查过,并且没有可能导致此错误的无效 ASCII 字符。
#!/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
有谁知道如何解决这一问题?提前谢谢了。