Commit 176ec403 by BellCodeEditor

save project

parent 07386f3a
Showing with 21 additions and 4 deletions
path = r'C:\Users\MAKCOO-03\Documents\lesson13-1\sales_list.txt'
with open(path, 'r', encoding='utf-8') as file:
for i in file.readlines():
path = r'C:\Users\MAKCOO-03\Documents\lesson13-3\sales_list.txt'
data = []
with open(path, 'r', encoding='utf-8') as file1:
for i in file1.readlines():
line = i.split(' ')
#print(line)
sum = 0
......@@ -8,5 +9,7 @@ with open(path, 'r', encoding='utf-8') as file:
sum += int(line[J + 1])
if len(line[-1]) > 1:
sum += int(line[-1][:len(line[-1])])
print(f'{line[0]}:{sum}元')
data.append(f'{line[0]}:{sum}元\n')
with open(r'C:\Users\MAKCOO-03\Documents\lesson13-3\sales_sum.txt', 'w', encoding='utf-8') as file2:
file2.writelines(data)
\ No newline at end of file
悟空:348元
诺依:380元
小贝:182元
李丽:201元
宋扬:107元
王明:245元
李强:164元
孙小白:222元
苏琪:137元
刘若若:147元
刘阳:226元
王胜男:123元
王娇:131元
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