我尝试了下面的代码,但我没有输出。
from itertools import ifilter
with open('urls.txt','rb') as f,open('fliteredlinks.txt','wb') as g:
g.writelines( ifilter(lambda line: 'wikepedia' in line, f))
答案 0 :(得分:0)
for l in open("urls.txt").readlines():
if not l.startswith("https://en.wikipedia.org") : print(l)
这会奏效。