有谁知道的 请告诉一下哇

从 D盘中读取"Python成绩.csv",根据读取到的分数按照分数

段将成绩修改为"优” (90分以上、含90分)”良” (80-89,含

80)“中(70-79,含70) “及格”(60-69,含60)“不及格”

(60分下)5个等次,并将最后的结果写入到D盘下的"Python

成绩1.sv"中。

with open('d:\\Python成绩.csv','r') as f:
    data = f.readlines()

student = [t.strip().split(',') for t in data]

with open('d:\\Python成绩1.csv','w') as f:
    for name,score in student:
        s = int(score)
        if s>=90:
            score = "优"
        elif s>=80:
            score = "良"
        elif s>=70:
            score = "中"
        elif s>=60:
            score = "及格"
        else:
            score = "不及格"
        f.write(','.join([name, score])+'\n')

Python成绩.csv
小张,90
小李,80
小钱,70
小明,60
小黑,50

Python成绩1.csv

img