这个程序怎么做?我用了很多方法,但它不起作用。这是代码。
def remove():
f1=open("Sample.txt",'r')
x=f1.read()
x.split()
f2=open("Result.txt",'w')
for i in x:
if 'the' not in i:
f2.write(i)
print(f2) # This is to view the result.
f2.close()
f1.close()
f2=open("Result.txt",'r')
f2.read()
remove()
我不是 100% 确定这是你所追求的,但可能是这样的:
text = open('Sample.txt', 'r').read()
text = text.replace('the', '')
with open('Result.txt', 'w') as f2:
f2.write(text)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句