Python 如何从另一个已删除空白的列表返回非空行列表? 你的其他职能在哪里? def get_poem_lines(poem): r""" (str) -> list of str Return the non-blank, non-empt

Python 如何从另一个已删除空白的列表返回非空行列表? 你的其他职能在哪里? def get_poem_lines(poem): r""" (str) -> list of str Return the non-blank, non-empt,python,Python,如何从另一个已删除空白的列表返回非空行列表? 你的其他职能在哪里? def get_poem_lines(poem): r""" (str) -> list of str Return the non-blank, non-empty lines of poem, with whitespace removed from the beginning and end of each line. >>> get_poem_lines('T

如何从另一个已删除空白的列表返回非空行列表?
你的其他职能在哪里?
def get_poem_lines(poem):
    r""" (str) -> list of str

    Return the non-blank, non-empty lines of poem, with whitespace removed 
    from the beginning and end of each line.

    >>> get_poem_lines('The first line leads off,\n\n\n'
    ... + 'With a gap before the next.\nThen the poem ends.\n')
    ['The first line leads off,', 'With a gap before the next.', 'Then the poem ends.']
result = [line.strip() for line in string.split('\n') if line]