import shutil
with open('/path/to/file', 'r') as f:
    with open('/path/to/file.new', 'w') as g:
        for line in f.readlines():
            if '/local/server' not in line:             
                g.write(line)
shutil.move('/path/to/file.new', '/path/to/file')

 


原文链接:https://segmentfault.com/q/1010000000124564

相关文章:

  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2021-12-07
猜你喜欢
  • 2022-12-23
  • 2021-05-28
  • 2022-01-25
  • 2022-12-23
  • 2021-07-03
  • 2022-01-11
  • 2021-12-21
相关资源
相似解决方案