0
I have a txt file that I am doing treatment to generate a layout in another txt file. When I use the command print
the same generates correctly, but when I put to write in another file it generates only the first line.
num = input ("Digite local: ")
num2 = input ("Digite sub local: ")
f = open("update_teste.txt","w+")
with open ('contagem.txt') as fo:
for s in fo:
print ("0",num, num2, s[0:12], s[14:19], sep="")
new = ("0"+ num+ num2+ s[0:12]+ s[14:19])
with open ("update_teste.txt", "w+") as arquivo:
arquivo.writelines (str(new))
print (new)
File count.txt:
1234567890128;00001
5687544567456;00001
7898433340878;00002
8888021201451;00002
update_teste.txt:
00100588880212014500002
Good morning, thank you very much ! It met my need perfectly.
– welinton