Mixing files and loops

后端 未结 4 657
Happy的楠姐
Happy的楠姐 2020-11-29 05:52

I\'m writing a script that logs errors from another program and restarts the program where it left off when it encounters an error. For whatever reasons, the developers of t

4条回答
  •  暖寄归人
    2020-11-29 06:34

    Here's a version without the ugly while True pattern and without other modules:

    for line in iter(original.readline, ''):
        if …:   # to the beginning of the title or abstract
            for i in range(lineNumber):
                print original.readline(),
            break
    

提交回复
热议问题