打印numpy数组

时间:2018-09-16 08:52:40

标签: python arrays python-3.x numpy

我有一个随机的numpy数组,我想在播放器名称旁边打印出来。现在,它在单个播放器旁边打印出整个数组,我要在其中打印索引0和播放器0的所有元素,然后增加播放器并打印出第二行元素等。

import numpy as np
import random

startPosition = []
for i in range (5):
    r = random.randint(1,5)
    if r not in startPosition: startPosition.append(r)

stats = np.random.randint(10,20,(5, 3))
d = {};

x = 5
while x > len(d):
    name = raw_input('Enter player name')
    d[name] = "";
names = d.keys()

from numpy  import array
arr = array(d)



for x in names:
    print  "Player:", x,",Scores:", ('\n'.join([''.join(['{:4}'.format(item) for item in row]) 
      for row in stats]))

0 个答案:

没有答案