Commit c4eeaf52 by BellCodeEditor

auto save

parent 165a9904
Showing with 24 additions and 16 deletions
def new_input():
total = []
while True:
unit=input("请输入:")
if unit=='q':
break
else:
try:
un=int(unit)
except:
print("请重新输入!")
else:
total.append(un)
print(total)
new_input()
\ No newline at end of file
#sum=0
#while True:
#i=input("请输入数字")
#if i=='q':
#break
#else:
#try:
#n=int(i)
#except:
#print("请输入一个整数")
#else:
#sum
with open('C:\\Users\\bellcode\\Desktop\\score.txt','r',encoding='utf-8')as fill:
a=fill.readlines()
c=''
for i in a:
sum=0
b=i.split()
for j in b[1:]:
sum+=int(j)
c=c+b[0]+str(sum)+'\n'
with open('C:\\Users\\bellcode\\Desktop\\score.txt','w',encoding='utf-8')as fill:
a=fill.writelines(c)
\ 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