Commit 9e86cd4b by BellCodeEditor

save project

parent 5b1ab8c8
Showing with 11 additions and 4 deletions
a = ['你好呀\n','悟空\n','我在贝尔编程学python\n']
with open(r"c:\Users\Administrator\Documents\lesson13-1\sales_list.txt","r",encoding = "UTF-8" ) as file:
file.writelines(a)
\ No newline at end of file
with open(r"c:\Users\Administrator\Documents\lesson13-1\sales_list.txt","r",encoding = "UTF-8" ) as file:
:with open(r"c:\Users\Administrator\Documents\lesson13-1\sales_list.txt","r",encoding = "UTF-8" ) as file
a = file.readlines()
final_sum = []
for i in a:
data = i.split()
sum = 0
......@@ -7,5 +8,7 @@ for i in a:
#print(data[1:])
for sales in data[1:]:
sum = sum+int(sales)
resurt = data[0]+str(sum)
print(resurt)
\ No newline at end of file
resurt = data[0]+str(sum)+'\n'
final_sum.append(resurt)
\ 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