该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
实现读取csv文件,文件里面是有限个百分数成绩(99.6、76.8等等)导出GPA 和等级
==================================
代码是这样,但是报错了,在score = float(sc)这行就报错了,下面有没有错误还不知道,大佬能帮看看嘛?
错误代码:TypeError: 'float' object is not subscriptable
import pandas as pd
data = pd.read_csv("scores.csv")
grade = []
GPA = []
JD = (score-50)/10
GPA.append(JD)
sc = "%6.1f" % score
score = float(sc)
n = print(score)
for i in (1,n):
if score[i]>= 95:
grade = "A+"
elif score[i] >= 90:
grade = "A"
elif score[i] >= 85:
grade = "A-"
elif score[i] >= 82:
grade = "B+"
elif score[i] >= 78:
grade = "B"
elif score[i] >= 75:
grade = "B-"
elif score[i] >= 71:
grade = "C+"
elif score[i] >= 66:
grade = "C"
elif score[i] >= 62:
grade = "C-"
elif score[i] >= 60:
grade = "D"
else:
grade = "F"
grade.append(grade)