Commit 72dd6a17 by BellCodeEditor

auto save

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