So I have this text file:
Hoi
Total: 5700
-
-
And this code to change the Total: value:
with open("TEST.txt") as f:
lines = f.readlines()
string = (lines[2])
stringNub = string.replace("Total: ","")
num = 300
sum = int(stringNub) + int(num)
with open('TEST.txt','r') as file:
filedata = file.read()
filedata = filedata.replace(stringNub, str(sum))
with open('TEST.txt','w') as file:
file.write(filedata)
This works but the result is minus one Enter '\n'.
Hoi
Total: 6000-
-
How do I keep it from removing this enter ?