Commit af092869 by BellCodeEditor

save project

parent 503d4d69
Showing with 0 additions and 7 deletions
......@@ -7,9 +7,4 @@ for i in a: #用for...in...把每一行的数据遍历
sum=0 #先把总钱数设为0
for j in data[1:]: #遍历列表中第1个数据和之后的数据
sum=sum+int(j)
result = data[0]+str(sum)+'\n' #结果就是学生姓名和总义卖款,后面加上换行符,写入的时候更清晰
final_sum.append(result) #每次把结果都补充到列表中
\ No newline at end of file
# 这里写入文件的时候,注意命名一个新的文件名哦
with open(r'C:\Users\Administrator\Desktop\ab.txt','a',encoding='utf-8') as file:
file.writelines(final_sum)
\ 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