两个语句进入打印循环

时间:2016-11-08 15:57:54

标签: python

我有一个程序可以打印出一个分数列表或排名列表,此时我有一个包含团队名称,分数和玩过的游戏的列表,但我也希望用range()打印出该位置。 代码如下:

for a in rankinglist:
    for pos in range(1, 33):
        print(format(pos) +
          format(a.name, '>18') +
          format(str(a.games), '>7') +
          format(str(a.score), '>11'))

rankinglist是团队列表,pos应该是1到32之间的范围。 我打算打印出来:

1             team1      0          0
2             team2      0          0
3             team3      0          0
4             team4      0          0
5             team5      0          0
6             team6      0          0
7             team7      0          0
8             team8      0          0
9             team9      0          0
10            team10     0          0
...

但是我得到循环,打印出每个团队32次。

1             team1      0          0
2             team1      0          0
3             team1      0          0
4             team1      0          0
5             team1      0          0
6             team1      0          0
7             team1      0          0
8             team1      0          0
9             team1      0          0
10            team1      0          0
11            team1      0          0
12            team1      0          0
13            team1      0          0
14            team1      0          0
15            team1      0          0
16            team1      0          0
17            team1      0          0
18            team1      0          0
19            team1      0          0
20            team1      0          0
21            team1      0          0
22            team1      0          0
23            team1      0          0
24            team1      0          0
25            team1      0          0
26            team1      0          0
27            team1      0          0
28            team1      0          0
29            team1      0          0
30            team1      0          0
31            team1      0          0
32            team1      0          0

任何人都知道解决这个问题的方法吗?

1 个答案:

答案 0 :(得分:2)

这个怎么样?

<div class="numberCircle">30</div>
<div class="numberCircle" style="font-size: 60px">1</div>
<div class="numberCircle" style="font-size: 12px">2</div>