105.408635, 109.058062109.711955, 107.612010106.770910, 107.178111104.902315, 108.942544106.429432, 109.986264106.350715, 108.745940107.208566, 106.724891105.758081, 107.954024106.635802, 105.702770109.028467, 105.940024104.741757, 109.545083104.469050, 105.768578105.860169, 106.943419104.190133, 108.945727108.427905, 107.905775105.105144, 108.668921105.584954, 110.006551105.130636, 105.577014106.174433, 106.636557107.386285, 108.500267107.742580, 110.253006107.594896, 106.710349109.138761, 106.629520...... .......Python读取txt文件,然后咋将第一列数字求平均值啊
1 回答
MMTTMM
TA贡献1869条经验 获得超4个赞
import sys sum = 0 cnt = 0 f = open('1.txt', 'r') s = f.readline() while (s): sum = sum + float(s.split(",")[0]) cnt = cnt + 1 s = f.readline() print(sum / cnt) f.close() 106.51093830434785
- 1 回答
- 0 关注
- 418 浏览
添加回答
举报
0/150
提交
取消