Commit fbfcaab7 by BellCodeEditor

save project

parent 72dd6a17
Showing with 12 additions and 12 deletions
with open(r'c:\Users\PC\Desktop\sales_list.txt','r',encoding='utf-8') as abc: with open(r'c:\Users\肖慧\Documents\lesson13-5\sales_list.txt','r',encoding='utf-8') as file:
a = abc.readlines() a = file.readlines()
file_sum = [] final_sum=[]
for i in a: for i in a:
data=i.split() data=i.split()
name = data[0]
yimai = data[1:]
sum = 0 sum = 0
for k in yimai: for sales in data[1:]:
sum = sum + int(k) sum = sum + int(sales)
result = data[0] + str(sum) + '\n' result = data[0] + str(sum) + \n
file_sum.append(result) final_sum.append(result)
with open(r'c:\Users\PC\Desktop\hello.txt','a',encoding="utf-8")as file: print(name + "总共捐款了" + str(sum) + "元")
file.writelines(file_sum)
\ No newline at end of file with open(r"c:\Users\肖慧\Desktop\wj.txt","r",encoding="uft-8") as file:
file.writelines(final_sum)
\ No newline at end of file
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