(python) 文档字符串导致缩进错误
def getText(nodelist):
"""Extracts the text between XML tags
I took this directly from http://docs.python.org/library/xml.dom.minidom.html.
For example, if I have a tag <Tag>525</Tag> this method returns me '525'
"""
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc
给我 IndentationError: unindent does not match any external indentation level
def getText(nodelist):
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc
不。我所做的就是删除文档字符串注释。到底是怎么回事?
def getText(nodelist):
"""Extracts the text between XML tags
I took this directly from http://docs.python.org/library/xml.dom.minidom.html.
For example, if I have a tag <Tag>525</Tag> this method returns me '525'
"""
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc
Gives me IndentationError: unindent does not match any outer indentation level
def getText(nodelist):
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc
Does not. All I am doing is deleting the docstring comment. What is going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的文档字符串以制表符开头。让您的代码仅使用空格进行缩进(或仅使用制表符),包括文档字符串的缩进。
Your docstring starts with tabs. Make your code only use spaces for indentation (or only tabs), including the indentation for the docstrings.
确保缩进时没有混合使用空格和制表符
Make sure you are not mixing spaces and tabs for your indentation