我有一个简短的代码片段,它不起作用,并不断给我这个错误:
我在我的代码里没有发现任何错误。。。我已经检查过了,没有可能导致此错误的无效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
有人知道怎么解决这个问题吗?非常感谢。你知道吗
检查是否存在卡舌。例如:在vim的正常模式下,输入:
/\t
你把制表符和空格混在一起了,这是不应该的。因为PEP 8 Style Guide空格的使用多于制表符,所以请尝试使用空格:D
相关问题 更多 >
编程相关推荐