简体   繁体   English

从 MATLAB 代码转换为 Python List 类型变量? 类型转换错误:列表列表索引必须是整数或切片,而不是元组

[英]Convert to Python List type variable from MATLAB code? Type convert error : List list indices must be integers or slices, not tuple

MATLAB MATLAB

BS = {};
Ksize = 2;
[value,index] = max(BSpar(:));
[r, c] = find(BSpar == value);

    for i = 1:K
            for j=1:K
                block =BS{r,c}((i-1)*Ksize+1:i*Ksize,(j-1)*Ksize+1:j*Ksize);

Python Python

BS = [];
Ksize = 2;
value = max(np.ravel(BSpar))
r, c= find(BSpar == value, nargout=2)
for i in range(K):
    for j in range(K):
        block = BS[r,c][i * Ksize:(i+1)*Ksize, j * Ksize:(j + 1) * Ksize]

Error:错误:

List indices must be integer or slices , not tuple.列表索引必须是整数或切片,而不是元组。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型错误“列表索引必须是整数或切片,而不是元组”(第6行) - Type error ' list indices must be integers or slices, not tuple' (line 6) Python:“列表索引必须是整数或切片,而不是元组” - Python:'list indices must be integers or slices, not tuple' “列表索引必须是整数或切片,而不是元组”错误 - "List indices must be integers or slices, not tuple" error 错误:列表索引必须是整数或切片,而不是元组 - Error: list indices must be integers or slices, not tuple 错误是“列表索引必须是整数或切片,而不是元组” - Error is 'list indices must be integers or slices, not tuple' 带有行和列的列表:类型错误:列表索引必须是整数或切片,而不是元组 - List With Row and Column : Type Error : list indices must be integers or slices, not tuple Python 错误:列表索引必须是整数或切片,而不是元组 - Python Error: list indices must be integers or slices, not tuple 类型错误:列表索引必须是整数或切片,而不是类型 - TypeError: list indices must be integers or slices, not type Python:从excel中提取数据类型错误:列表索引必须是整数或切片,而不是str - Python: Pulling data from excel Type error: list indices must be integers or slices, not str 垂直切片:列表索引必须是整数或切片,而不是元组错误 - Vertical Slices: list indices must be integers or slices, not tuple error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM