import random
#%%
Subject=['math','english','chinese','history','physics']
sub_scores=[]
for num in range(100):
scores=[random.randrange(60,100+1) for i in range(5)]
sub_scores.append(str(scores)[1:-1]+'\n')
sub_scores.insert(0,",".join(Subject)+'\n')
print(sub_scores)
# 第一行
firstline=sub_scores[0].split(',')
#%%
information_format = []
for line in sub_scores:
information_current=line.split(',')
information_str = ''
for column in information_current:
information_str += column.strip().ljust(len(firstline[information_current.index(column)])+4,' ')
information_str+='\n'
information_format.append(information_str)
print(information_format)
with open('stu_scores.txt','w') as fw:
fw.writelines(information_format)