【python- 学习】简单文件操作

帮一个大一学生写试题
【python- 学习】简单文件操作

path = 'read.txt'
f1 = open(path,encoding='utf8').readlines()

avge_score_list = []
for con in f1:
    avge_score = con.strip().split(',')[2]
    avge_score_list.append(int(avge_score))
print(avge_score_list)
print('%.2f'%mean(avge_score_list))

for con in f1:
    score = int(con.strip().split(',')[2])
    old = int(con.strip().split(',')[1])
    # print(score,old)
    if score<60 and old>20:
        with open('write.txt','a',encoding='utf8') as fn:
            fn.write(con)
[78, 30, 77, 6, 4, 30, 44, 49, 7, 74, 74, 44, 64, 63, 29, 22, 21, 51, 52, 52, 56, 5, 100, 71, 93, 12, 80, 54, 74, 54, 62, 70, 50, 33, 86, 67, 30, 15, 3, 35, 73, 41, 60, 42, 26, 87, 24, 28, 0, 43, 67, 81, 90, 34, 87, 18, 95, 1, 50, 5, 57, 43, 97, 81, 53, 30, 43, 63, 38, 0, 41, 35, 20, 55, 78, 14, 50, 15, 73, 11, 14, 9, 72, 37, 49, 29, 37, 61, 91, 5, 73, 24, 55, 17, 99, 73, 1, 79, 91, 4, 39, 4, 44, 80, 54, 16, 3, 41, 7, 52, 73, 59, 61, 91, 55, 42, 36, 56, 14, 4, 20]

45.79