def main():
file = open("score.txt", encoding='UTF-8')
readData = []
while 1:
line = file.readline()
if not line:
break
splitLine = line.replace('\n', '').split(',')
readData.append(splitLine)
file.close()
print("读取score文件,其数据为:")
print(readData)
readData.pop(0)
for value in readData:
score = round(int(value[1])*0.4+int(value[2])*0.6)
value.append(str(score))
print("其运算结果为:")
readData.sort(key=lambda x: x[3],reverse=True)
# sorted(readData)
print(readData)
if __name__ == '__main__':
main()
python1
最新推荐文章于 2024-05-20 23:13:32 发布