这么简单实现行吗
sum = 0.0
count = 0
with open('numbers.txt', 'a') as f:
while True:
value = input('Input number:')
if value == '':
break
sum = sum + float(value)
count += 1
f.write(value + '\n')
f.write('avg= ' + str(sum / count) + '\n')
print('avg= ' + str(sum / count) + '\n')
a=(2,2,4,5,6,7,3.0, 5.5)
avg = sum(a) / len(a)
print avg