search and replace first amount of strings instances with one thing and a second amount of instances with another thing-
validationmail1 at gmail.com
validationmail1 at gmail.com
Fri Sep 22 10:09:01 EDT 2017
i have a code in python to search and replace what i need though is to replace the first say 10 instances of the number 1 with 2 and the second 10 instances with the number 3. anybody knows how to do that?
fin = open(r'F:\1\xxx.txt')
fout = open(r'F:\1\xxx2.txt', "wt")
for line in fin:
fout.write( line.replace('1', '2') )
fin.close()
fout.close()
More information about the Python-list
mailing list