myfile = open('Results.txt')
title = '{0:20} {1:20} {2:20} {3:20} {4:20}'.format('Player Nickname','Matches Played','Matches Won','Matches Lost','Points')
print(title)
for line in myfile:
item = line.split(',')
points = int(item[2]) * 3
if points != 0:
result = '{0:20} {1:20} {2:20} {3:20} {4:20}'.format(item[0], item[1], item[2], item[3],points)
print(result)
嗨,那里只是需要一些帮助,那些知道如何正确使用.format,出于某种原因,当打印答案时。我会期待这一点。代码不以正确的格式打印
Player Nickname Matches Played Matches Won Matches Lost Points
Leeroy 19 7 12 21
但显示的输出我得到的是这种
Player Nickname Matches Played Matches Won Matches Lost Points
Leeroy 19 7 12
21
21被显示在错误的地方。我做错了什么?
没有我写了出来 继承人的输出 '玩家昵称比赛场次比赛赢得比赛失分 Leeroy 19 7 12 21' –