用Python 2.7打印

时间:2014-10-10 04:43:55

标签: python-2.7

Class = ["Gabriel","Isabella","Veronica","Hunter","John"]
num = [1,2,3,4,5]


for i in num :
    for z in Class :
        print "%d.  %s"%(i,z)

上面是打印这个:

1.  Gabriel
1.  Isabella
1.  Veronica
1.  Hunter
1.  John
2.  Gabriel
2.  Isabella
2.  Veronica
2.  Hunter
2.  John
3.  Gabriel
3.  Isabella
3.  Veronica
3.  Hunter
3.  John
4.  Gabriel
4.  Isabella
4.  Veronica
4.  Hunter
4.  John
5.  Gabriel
5.  Isabella
5.  Veronica
5.  Hunter
5.  John
     

我希望每次只有这样一次:

     
      
  1. 加布里埃尔
  2.   
  3.   
  4. 婆婆纳
  5.   
  6. 亨特
  7.   
  8. 约翰
  9.   

1 个答案:

答案 0 :(得分:1)

for i,z in zip(num, Class):
    print "%d.  %s"%(i,z)