Commit 713c7308 by BellCodeEditor

auto save

parent 5ec53ebb
Showing with 13 additions and 0 deletions
with open(r'c:\Users\Administrator\Desktop\培训\test.txt','r',encoding='utf-8') as file:
a=file.readlines()
list=[]
for i in a:
num=0
b=i.split()
for d in b[1:]:
num=num+int(d)
ji=b[0]+' '+str(num)+'\n'
list.append(ji)
print(list)
with open(r'c:\Users\Administrator\Desktop\培训\test.txt','w',encoding='utf-8') as file:
file.writelines(list)
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