Commit b3cd8957 by BellCodeEditor

save project

parent 8b64e46d
Showing with 12 additions and 3 deletions
with open(r'c:\Users\dell\Documents\lesson13-1\sales_list.txt',"r",encoding="utf-8") as file: with open(r'c:\Users\dell\Documents\lesson13-1\sales_list.txt',"r",encoding="utf-8") as file:
a=file.readlines() a=file.readlines()
#print(a) #print(a):
file123=[]
for i in a: for i in a:
#print(i) #print(i)
new_i=i.split() new_i=i.split()
print(new_i) #print(new_i[1:])
\ No newline at end of file sum=0
for sales in new_i[1:]:
sum=sum+int(sales)
result=new_i[0]+str(sum)+"\n"
#print(result)
file123.append(result)
with open(r'c:\Users\dell\Desktop\新建文本文档.txt',"w",encoding="utf-8") as file1:
file1.writelines(file123)
\ 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