Commit e3a8646f by BellCodeEditor

save project

parent 228a91b0
Showing with 8 additions and 3 deletions
with open(r"c:\Users\Administrator\Documents\lesson13-1\sales_list.txt","r",encoding="utf-8")as file:
a=file.readlines()
e=[]
for i in a:
b=i.split()[1:]
c=0
for j in b:
c+=int(j)
print(i.split()[0]+str(c))
e.append(i.split()[0]+str(c)+"\n")
with open(r"c:\Users\Administrator\Desktop\新建文本文档.txt","w",encoding="utf-8")as file:
file.writelines(e)
......
a=["1\n","2aa"]
with open(r"c:\Users\Administrator\Desktop\新建文本文档.txt","a",encoding="utf-8") as file:
file.writelines(a)
\ 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