import random
import string
list_index=["名次","学号","姓名","语文","数学","英语","总分","均分"] #定义字段名
list_name=["赵云","关羽","张飞","黄忠","马超","张三","李四","李五","赵四","苏苏"] #定义名字
list_num=[]
dict_num={}
for i in range(0,len(list_name)):
T=[]
for j in range(0,3):
T.append(random.randint(50,100))
T.append(sum(T))
T.append(T[-1]/len(T))
T.insert(0,list_name[i])
T.insert(0,2000+i)
list_num.append(list(T))
T.clear()
list_num=sorted(list_num,key=(lambda x:x[6]))
list_num.reverse()
for i in range(0,len(list_name)):
dict_num[str(i+1)]=list_num[i]
print("成绩统计表".center(54,"#"))
print(str(list_index[0]).center(6),end=" ")
for j in range(1,8): #循环输出所有字段名
print(list_index[j].center(5),end=" ")
print()
print("="*57)
for i,j in dict_num.items():
print(str(i).center(8),end=" ")
for x in j:
print(str(x).center(6),end=" ")
print()
print("="*57)