开发者

(python) docstring is causing indentation error

开发者 https://www.devze.com 2022-12-19 17:14 出处:网络
def getText(nodelist): \"\"\"Extracts the text between XML tags I took this di开发者_如何学Pythonrectly from http://docs.python.org/library/xml.dom.minidom.html.
def getText(nodelist):
    """Extracts the text between XML tags

    I took this di开发者_如何学Pythonrectly 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消