Commit 604cb9b9 by BellCodeEditor

save project

parent 12755e16
Showing with 11 additions and 4 deletions
#file = open(r"C:\Users\no3\Documents\lesson12-1\sales_list.txt",'r',encoding='utf-8') #file = open(r"C:\Users\no3\Documents\lesson12-1\sales_list.txt",'r',encoding='utf-8')
final_sum=[]
with open(r'C:\Users\no3\Documents\lesson12-1\sales_list.txt','r',encoding='utf-8')as file: with open(r'C:\Users\no3\Documents\lesson12-1\sales_list.txt','r',encoding='utf-8')as file:
a = file.readlines() a = file.readlines()
for i in a: for i in a:
...@@ -6,4 +7,7 @@ with open(r'C:\Users\no3\Documents\lesson12-1\sales_list.txt','r',encoding='utf- ...@@ -6,4 +7,7 @@ with open(r'C:\Users\no3\Documents\lesson12-1\sales_list.txt','r',encoding='utf-
sum = 0 sum = 0
for sales in data[1:]: for sales in data[1:]:
sum += int(sales) sum += int(sales)
print(data[0]sum) result = data[0]+str(sum)+'\n'
\ No newline at end of file final_sum.append(result)
with open(r'C:\Users\no3\Documents\lesson12-1\new_sales_list.txt','a',encoding='utf-8')as file:
file.writelines(final_sum)
\ No newline at end of file
悟空153
小贝167
诺依165
悟空 12 15 11 12 11 12 14 13 15 17 21 悟空 12 15 11 12 11 12 14 13 15 17 21
小贝 11 14 17 14 19 10 17 16 15 14 20 小贝 11 14 17 14 19 10 17 16 15 14 20
诺依 12 17 15 14 13 19 18 11 11 10 25 诺依 12 17 15 14 13 19 18 11 11 10 25
\ 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