I am new to Python programming...
I have a .txt file....... It looks like..
0,Salary,14000
0,Bonus,5000
0,gift,6000
I want to to replace
o=open("output.txt","w") for line in open("file"): s=line.split(",") s[0]="1" o.write(','.join(s)) o.close()
Or you can use fileinput with in place edit
import fileinput for line in fileinput.FileInput("file",inplace=1): s=line.split(",") s[0]="1" print ','.join(s)