V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  Reo  ›  全部回复第 1 页 / 共 1 页
回复总数  1
@paloalto :Hi paloalto, 我刚学Python, 现在也有一个跟你一样的问题想解决。能把你对于这个问题的代码share一下吗?非常感谢~
我写的代码还是有问题,list_2 中如果某行包含list_1中的某行,这样的就删不掉(我的是把包含的输出到一个文件中),只有当list_2和list_1两行完全一样才被删掉。我的代码如下:
fileOne = open("a.txt", "r").readlines()
fileTwo = open("b.txt", "r").readlines()
outFile = open("c.txt", "w")
for i in fileOne:
for j in fileTwo:
if j in i:
outFile.write(i)
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3006 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 11:44 · PVG 19:44 · LAX 04:44 · JFK 07:44
Developed with CodeLauncher
♥ Do have faith in what you're doing.