Workingwithtext

From XPUB & Lens-Based wiki
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Replacing words and output in txt

#import time
f = open('filename.txt')
print f

out = open('newfilename.txt', 'w') 

for line in f:
	line = line.strip().lower()
	text = line.replace('old' , 'new')
	#time.sleep(.2)
	print text 
	out.write(text)
	
out.close()