Commit 044e8181 by BellCodeEditor

auto save

parent ba88541e
Showing with 10 additions and 3 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:
print(i,end='') j = i.split() #用空格将字符串进行分割,a形成一个列表,分割后的元素数据类型为字符串
\ No newline at end of file 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