Commit 1af2d727 by BellCodeEditor

save project

parent 17c83729
Showing with 7 additions and 3 deletions
with open(r"C:\Users\Administrator\Desktop\新建文本文档.txt","r",encoding="utf-8") as file:
a=file.readlines()
asum=[]
for i in a:
da=i.split()
sum=0
for b in da[1:]:
sum=sum+int(b)
yesult=da[0]+str(sum)
print(yesult)
\ No newline at end of file
yesult=da[0]+str(sum)+"\n"
asum.append(yesult)
with open(r"C:\Users\Administrator\Desktop\新建文本文档.txt","a",encoding="utf-8") as file:
file.writelines(asum)
print(asum)
\ 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