Commit 21c74dcd by BellCodeEditor

save project

parent e8061b74
Showing with 10 additions and 6 deletions
file=open(r'c:\Users\刁敬凯\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8') file=open(r'c:\Users\刁敬凯\Documents\lesson13-3\sales_list.txt','r',encoding='utf-8')
a=file.readlines() a=file.readlines()
#print(a) print(a)
file.close() f=[]
for i in a: for i in a:
# print(i) # print(i)
p=i.split() p=i.split()
...@@ -10,5 +10,10 @@ for i in a: ...@@ -10,5 +10,10 @@ for i in a:
s='' s=''
for sa in p[1:]: for sa in p[1:]:
sum+=int(sa) sum+=int(sa)
s=p[0]+str(sum) s=p[0]+str(sum)+'\n'
print(s) print(s)
\ No newline at end of file f.append(s)
#print(f)#file.close() # print(f)
with open(r'c:\Users\刁敬凯\Desktop\a.txt','w',encoding='utf-8')as file1:
file1.writelines(f)
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