请问用python怎么解决

 

dic = {"A":0,"B":0,"C":0,"D":0,"E":0,"F":0}
with open("score.txt","r", encoding='utf-8') as f:
    for line in f:
        n,s = line.strip().split(",")
        s = float(s)

        if s>=90:
            f = "A"
        elif s>=80:
            f = "B"
        elif s>=70:
            f = "C"
        elif s>=60:
            f = "D"
        else:
            f = "F"
        dic[f]+=1
        print(n,s,f)
print(dic)

 

a = 0
b = 0
c = 0
d = 0
e = 0
with open(r'E:\1.txt', 'r') as f:
    for n in f.readlines():
        i = int(n.strip())
        if 89 < i < 100:
            a += 1
        elif 79 < i < 90:
            b += 1
        elif 69 < i < 80:
            c += 1
        elif 59 < i < 70:
            d += 1
        else:
            e += 1
    print("A等级人数:{}人".format(a))
    print("B等级人数:{}人".format(b))
    print("C等级人数:{}人".format(c))
    print("D等级人数:{}人".format(d))
    print("E等级人数:{}人".format(e))

 

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632