import csv
name='midterm.csv'
with open(name,"r") as file_object:
reader=csv.reader(file_object)
header=next(reader)
rows=[row[1] for row in reader]
def criteria(score):
if score <= 100 and score >= 90:
return'A'
elif score < 90 and score >= 80:
return'B'
elif score < 80 and score >= 70:
return'C'
elif score < 70 and score >= 60:
return'D'
elif score < 60:
return'F'
pi_string=[]
for message in rows:
pi_string.append(criteria(float(message)))
first_number=[pi_string.count('A'),pi_string.count('B'),pi_string.count('C'),pi_string.count('D'),pi_string.count('F')]
import plotly
hist=plotly.bar()
hist.x_labels=['A','B','C','D','F']
hist.answer('score',first_number)
hist.render_to_file('midterm1.svg')
把你的 import plotly 改成下面这个 import plotly.plotly import plotly.graph_objs as pg