Copying from one text file to another using Python

前端 未结 8 1830
死守一世寂寞
死守一世寂寞 2020-11-30 01:56

I would like to copy certain lines of text from one text file to another. In my current script when I search for a string it copies everything afterwards, how can I copy jus

8条回答
  •  自闭症患者
    2020-11-30 02:21

    f=open('list1.txt')  
    f1=open('output.txt','a')
    for x in f.readlines():
        f1.write(x)
    f.close()
    f1.close()
    

    this will work 100% try this once

提交回复
热议问题