Commit f27e734f by BellCodeEditor

auto save

parent 0475384b
Showing with 6 additions and 2 deletions
with open(r'c:\Users\PC\Desktop\sales_list.txt','r',encoding='utf-8') as abc: with open(r'c:\Users\PC\Desktop\sales_list.txt','r',encoding='utf-8') as abc:
a = abc.readlines() a = abc.readlines()
file_sum = []
for i in a: for i in a:
data=i.split() data=i.split()
name = data[0] name = data[0]
...@@ -7,4 +8,7 @@ for i in a: ...@@ -7,4 +8,7 @@ for i in a:
sum = 0 sum = 0
for k in yimai: for k in yimai:
sum = sum + int(k) sum = sum + int(k)
print(name + "总共捐款了" + str(sum) + "元") result = data[0] + str(sum) + '\n'
\ No newline at end of file file_sum.append(result)
with open(r'c:\Users\PC\Desktop\hello.txt','a',encoding="utf-8")as file:
file.writelines(file_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