Jan-29-2019, 05:42 PM
I need your help (again)
I try to get the number who is stock in the line I need to get. this number can be up to three digits (like ###) and I need to get it and make a var with it, increment it by one, and replace the value in the line per the new value but keeping the other lines intact. my text file look like that.
I have already try this:
I try to get the number who is stock in the line I need to get. this number can be up to three digits (like ###) and I need to get it and make a var with it, increment it by one, and replace the value in the line per the new value but keeping the other lines intact. my text file look like that.
14 23 3 7 58 1 7 41 41 327my text file have 40 line (but I don't think that will impact the script)
I have already try this:
f = open("C:\data\data.txt") line=f.readlines(1) f.close() line=str(line) try: line=int(line) except ValueError: pass line+1 print(line) open("C:\data\data.txt",'w').write(lines.join(line)) breakbut they write 0 whatever the file contain. and I try many other solution was never result except error message. I have search for answer for my problem in many forum, maybe I search in the wrong place. I am really grateful to you who answers us, is probably not easy and you do your possible each time to reply to everybody. thank you.