尝试了很多次,要么就是如图,要么就是报错,求解

img


我想请教一下,如果我想让整段文字,例如平均分为:68.80,这段文字居中对齐,我应该在哪里添加center呢,因为添加之后运行,他只有分数居中,如图

img

修改后的代码如下,望采纳

#算平均分、最高分
average = round (sum(scores) / Len(scores), 2)
print("平均分为:{:.2f}".format(average).center(20))
print("最高分为:{:.2f}".format(max(scores)).center(20))
print("最低分为:{:.2f}".format(min(scores)).center(20))

写法有误,要整段文字居中就不能用逗号在print,换一下写法
print("平均分为:{}".format(scores).center(20))