Commit 715cb97e by BellCodeEditor

save project

parent c220a4e5
Showing with 9 additions and 2 deletions
a=['你好呀\n','悟空\n','我在贝尔编程学python\n']
with open(r'c:\Users\Makcoo-Bellcode\Desktop\新建文本文档.txt','a',encoding='utf-8') as file:
file.writelines(a)
\ No newline at end of file
with open(r'C:\Users\Makcoo-Bellcode\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8')as file: with open(r'C:\Users\Makcoo-Bellcode\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8')as file:
a=file.readlines() a=file.readlines()
#print(a) #print(a)
end_list=[]
for i in a: for i in a:
data=i.split() data=i.split()
#print(data[1:]) #print(data[1:])
...@@ -8,4 +9,6 @@ for i in a: ...@@ -8,4 +9,6 @@ for i in a:
for b in data[1:]: for b in data[1:]:
total=total+int(b) total=total+int(b)
end=data[0]+str(total) end=data[0]+str(total)
print(end) end_list.append(end)
\ No newline at end of file with open(r'C:\Users\Makcoo-Bellcode\Documents\lesson13-1\sales_list.txt','w',encoding='utf-8')as file:
file.writelines(end_list)
\ 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