Commit 50b6478b by BellCodeEditor

save project

parent f3f4ec4a
Showing with 10 additions and 4 deletions
with open(r'c:\Users\Lenovo\Documents\lesson13-1\sales_list.txt' , 'r' , encoding = 'utf-8') as file:
a = file.readlines()
result = []
total = 0
for i in a:
data = i.split()
sum = 0
for j in data[1:]:
sum += int(j)
print(data[0] + str(sum))
\ No newline at end of file
sum += int(j)
total += sum
result.append(data[0] + str(sum) + '\n')
result.append('总和:' + str(total))
print(result)
with open(r'c:\Users\Lenovo\Documents\lesson13-1\1.txt' , 'w' , encoding = 'utf-8') as file:
file.writelines(result)
\ 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