Commit 262d4deb by BellCodeEditor

save project

parent 044e8181
Showing with 4 additions and 9 deletions
with open(r'C:\Users\yd\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8') as f1: with open(r'C:\Users\yd\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8') as f1:
date = f1.readlines() #把每行作为一个元素放到一个大列表中 date = f1.readlines()
new_date = []
for i in date: for i in date:
j = i.split() #用空格将字符串进行分割,a形成一个列表,分割后的元素数据类型为字符串 print(i,end='')
sum = 0
for k in j[1:]:
sum = sum+int(k)
with open(r'C:\Users\yd\Desktop\捐赠信息.txt','a',encoding='utf-8') as f2:
f2.write(j[0]+str(sum)+'\n') #参数为一个列表,写入列表信息
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