diff --git a/area.py b/area.py index 694ebc4..16d519f 100644 --- a/area.py +++ b/area.py @@ -1,15 +1,23 @@ -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