Commit 6bf304b1 by BellCodeEditor

save project

parent f1e9fd0b
Showing with 4 additions and 3 deletions
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
with open(r'c:\Users\Administrator\Desktop\新建文本文档.txt','r',encoding='utf-8') as file: with open(r'c:\Users\Administrator\Desktop\新建文本文档.txt','r',encoding='utf-8') as file:
a = file.readlines() a = file.readlines()
k=[]
for i in a: for i in a:
#print(i) #print(i)
c = i.split() c = i.split()
...@@ -12,8 +13,8 @@ for i in a: ...@@ -12,8 +13,8 @@ for i in a:
for q in c[1:]: for q in c[1:]:
sum += int(q) sum += int(q)
d = c[0]+str(sum) d = c[0]+str(sum)+'\n'
print(d) k.append(d)
with open(r'c:\Users\Administrator\Desktop\新建文本文档.txt','a',encoding='utf-8') as file: with open(r'c:\Users\Administrator\Desktop\新建文本文档.txt','a',encoding='utf-8') as file:
file.writelines(d) file.writelines(k)
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