Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

bellcode / lesson13-4

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Switch branch/tag
  • lesson13-4
  • diy.py
Find file
BlameHistoryPermalink
  • BellCodeEditor's avatar
    save project · 12ef6e50
    BellCodeEditor committed 3 years ago
    12ef6e50
diy.py 456 Bytes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
with open(r'c:\Users\joy\Documents\lesson13-1\sales_list.txt','r',encoding="utf-8")as file1:
     a=file1.readlines()
     #print(a)
fin_sun=[]
for i in a:
    num=i.split()
    #print(num[0])
    #print(num[1:])
    sun=0
    for seles in num[1:]:
        sun=sun+int(seles)
    res=num[0]+str(sun)+"\n"
    fin_sun.append(res)


with open(r'C:\Users\joy\Desktop\sales_list.txt','w',encoding="utf-8")as file1:
    file1.writelines(fin_sun)