Commit d0298994 by BellCodeEditor

save project

parent b21b56f7
Showing with 6 additions and 4 deletions
with open(r'c:\Users\li\Documents\lesson13-4\sales_list.txt','r',encoding='utf-8') as file1:
a=file1.readlines()
result_sum=[]
for i in a:
data=i.split()
b=data[1:]
sum=0
for c in b:
sum=sum+int(c)
result=data[0]+':'+str(sum)
result=data[0]+':'+str(sum)+'\n'
result_sum.append(result)
with open(r'D:\wenjianjia\新建文件夹 (7)\总和.txt','w',encoding='utf-8') as file2:
file2.writelines(result_sum)
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