Workingwithtext: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
 
Line 4: Line 4:
<source lang="python">
<source lang="python">
#import time
#import time
f = open('facebookdatapolicy.txt')
f = open('filename.txt')
print f
print f


out = open('newfilenikos.txt', 'w') #saveas
out = open('newfilename.txt', 'w')  


for line in f:
for line in f:
line = line.strip().lower()
line = line.strip().lower()
text = line.replace('facebook' , 'THE WORLD WE CREATED FOR YOU TO FIT YOUR SELF COMFORTABLY')
text = line.replace('old' , 'new')
#time.sleep(.2)
#time.sleep(.2)
print text  
print text  

Latest revision as of 23:05, 18 November 2013

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()