Commit 5ba020a0 by BellCodeEditor

auto save

parent c62964ee
Showing with 16 additions and 0 deletions
with open(r'c:\Users\Administrator\Documents\lesson13-1\sales_list.txt','r',encoding='UTF-8') as file:
a = file.readlines()
final_num = []
for i in a:
StrLine = i.split()
data = StrLine[1:]
count = 0
for j in data:
count += int(j)
b = StrLine[0] + str(count) +'\n'
final_num.append(b)
with open(r'c:\Users\Administrator\Desktop\新建文本文档.txt','w',encoding='UTF-8') as file1:
file1.writelines(final_num)
\ 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