fork download
  1. with open('log.log', 'rt', encoding='utf-8') as file:
  2. buf = []
  3. result = []
  4. for line in file:
  5. line = line.rstrip()
  6. if len(buf) and line.startswith('Warning'):
  7. result.append(' '.join(buf))
  8. buf = []
  9. buf.append(line)
  10.  
  11. if len(buf):
  12. result.append(' '.join(buf))
  13.  
  14. print(result)
  15.  
Runtime error #stdin #stdout #stderr 0.14s 23528KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
    with open('log.log', 'rt', encoding='utf-8') as file:
FileNotFoundError: [Errno 2] No such file or directory: 'log.log'