Workingwithtext: Difference between revisions
(Created page with "<source lang="python"> #import time f = open('facebookdatapolicy.txt') print f out = open('newfilenikos.txt', 'w') #saveas for line in f: line = line.strip().lower() text ...") |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Replacing words and output in txt | |||
<source lang="python"> | <source lang="python"> | ||
#import time | #import time | ||
f = open(' | f = open('filename.txt') | ||
print f | print f | ||
out = open(' | out = open('newfilename.txt', 'w') | ||
for line in f: | for line in f: | ||
line = line.strip().lower() | line = line.strip().lower() | ||
text = line.replace(' | 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()