def every_second_line(report):
""" (Open File for reading) -> list of str
Return a list containing every second line (with leading and trailing
whitespace removed) in report, starting with the first line.
"""
答案 0 :(得分:0)
如果我没记错的话,你会这样做:
def every_second_line(report_location):
""" This code will return every second line with trailing whitespace stripped."""
report = open(report_location, rb+)
second_lines = [a.strip() for a in report.readlines()[1::2]]
return second_lines
目前我还没有Python,但这应该有效。祝你好运!