[英]List With Row and Column : Type Error : list indices must be integers or slices, not tuple
BS
is the list. BS
是列表。 I would like to add a BS
List with rows and columns to define others places.我想添加一个带有行和列的BS
列表来定义其他地方。
But i'm getting the error:但我得到了错误:
TypeError: list indices must be integers or slices, not tuples TypeError:列表索引必须是整数或切片,而不是元组
Do I need to change the BS
datatype from something such as Cell Array
, or tuple
?我是否需要从诸如Cell Array
或tuple
之类的东西中更改BS
数据类型?
BS = []
BS.append([])
value = max(ravel(BSpar))
[r, c]= find(BSpar == value, nargout=2)
for j in range(K):
block = BS[r,c][i * Ksize:(i - 1) * Ksize, j * Ksize:(j + 1) * Ksize]
Bblock[i].append(block)
ravel
未定义,您的缩进似乎也已关闭。
[i * Ksize:(i - 1) * Ksize, j * Ksize:(j + 1) * Ksize] [i * Ksize:(i - 1) * Ksize, j * Ksize:(j + 1) * Ksize]
The above is of form [A:B:C]
where:以上是[A:B:C]
的形式,其中:
A is i * Ksize
A 是i * Ksize
B is (i - 1) * Ksize, j * Ksize
B 是(i - 1) * Ksize, j * Ksize
C is (j + 1) * Ksize
C 是(j + 1) * Ksize
B is where the problem is - there is a comma, which indicates it is a tuple of two numbers, but you are only allowed a single number there. B 是问题所在 - 有一个逗号,表示它是两个数字的元组,但那里只允许一个数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.