Commit 3cdda9a8 by BellCodeEditor

save project

parent df6a2e90
Showing with 5 additions and 3 deletions
with open(r'C:\Users\Administrator\Desktop\text.txt','r',encoding='gbk')as file:
a=file.readlines()
#print(a)
p=[]
for i in a:
b=i.split()
#print(b)
sum=0
for c in b[1:]:
sum=sum+int(c)
d=b[0]+str(sum)
print(d)
d=b[0]+str(sum)+'\n'
p.append(d)
with open(r'C:\Users\Administrator\Desktop\fj (1).txt','w',encoding='utf-8') as file:
file.writelines(p)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment