2次元配列を持つので、アイテムのそれぞれにn *回クローンします。 これは、両方のディメンションでイメージをn倍に拡大するのとまったく同じです。 thteエラーの配列操作:エラー: 'int'オブジェクトがアイテム割り当てをサポートしていません
Traceback (most recent call last):
File "<ipython-input-14-508f439a1888>", line 1, in <module>
elargir (a,5)
File "<ipython-input-12-b2382eb5b301>", line 5, in elargir
imag[i][j]=a[i//5][j//n]
TypeError: 'int' object does not support item assignment
おかげで、私は配列
a=np.array([[1,2],[3,4]])
を作成し、それに
elargir (a,5)
を関数を適用
def elargir(a,n) :
imag=[a.shape[0]*n,a.shape[1]*n] # Array with the wanted shape
for i in range(a.shape[0]):
for j in range(a.shape[1]*n): # loops on lines and columns of a
imag[i][j]=a[i//5][j//n]
return imag
とここにある: はここに私のコードですあなたの助け
[例外TypeError:「int型のオブジェクトは、アイテムの割り当てをサポートしていません]の可能な重複(http://stackoverflow.com/questions/14805306/typeerror-int-object-does-not-support-item-assignment ) –
この 'imag = [a.shape [0] * n、a.shape [1] * n]'は、 'a.shape [0] * n'と' a.shape [1] ] * nである。 – khelwood