Commit 5fbeab95 by BellCodeEditor

auto save

parent 60a8190b
Showing with 17 additions and 3 deletions
with open(r'c:\Users\Administrator.QG-20190326CAWA\Documents\lesson13-1\test.txt','r',encoding='utf-8') as file: with open(r'c:\Users\Administrator.QG-20190326CAWA\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8') as file:
a=file.read() a=file.readlines()
\ No newline at end of file final_sum=[]
for i in a:
b=i.split()
# print(b[0],end=" ")
# print(b[1:])
sum=0
#for 循环遍历
for k in b[1:]:
sum=sum+int(k)
result=b[0]+str(sum)+'\n'
final_sum.append(result)
#print(result)
with open(r'C:\Users\Administrator.QG-20190326CAWA\Desktop\test.txt','w',encoding='utf-8') as file:
\ 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