我完全不知道如何将列表更改为 int。
#Creates a list which is populated by whole names and scores
whole_names = list()
scores = list()
for line in lines:
# Makes each word a seperate object
objects = line.split(" ")
# Joins the first and last name of every line and makes them
their own seperate objects
whole_names.append(" ".join(objects[0:2]))
# Makes the scores of every line an object
scores.append(objects[2:3])
rect = Rectangle(Point(2, y-50), Point(scores[0],y-25))
rect.setFill("darkgreen")
rect.draw(win)
问题是, Point(scores[0], y-25)) 不会填充,因为 scores[0] 是一个列表,而不是一个 int,所以它在技术上不能是一个坐标,而是 score[0] 的实际值该列表将是一些随机数,我不知道它将是什么数字,但实际上它将是一个整数。那么如何将 score[0] 转换为随机整数呢?我试过 score = int(scores) 但这根本不起作用。