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()
#print(a)
file.close()
print(a)
f=[]
for i in a:
# print(i)
p=i.split()
......@@ -10,5 +10,10 @@ for i in a:
s=''
for sa in p[1:]:
sum+=int(sa)
s=p[0]+str(sum)
print(s)
\ No newline at end of file
s=p[0]+str(sum)+'\n'
print(s)
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