np.tile() 重复生成数组

np.tile(a,n)

功能是将a(a可以不是数组)重复n次,构成一个新的数组,n可以是int,或者是tuple

1.n是int

from numpy import *
a=[0,1,2]
tile(a,2)
#array([0, 1, 2, 0, 1, 2])

2.n是tuple(i,j)

反正就是把a作为一个整体,行重复i此,列重复j次

from numpy import *
a=[0,1,2]
tile(a,(2,2))

'''
array([[0, 1, 2, 0, 1, 2],
       [0, 1, 2, 0, 1, 2]])
'''

 

posted on 2020-09-04 15:22  小小喽啰  阅读(663)  评论(0编辑  收藏  举报