当前位置:主页 > 软件编程 > Python代码 >

python_array[0][0]与array[0,0]的区别详解

时间:2021-02-01 09:55:03 | 栏目:Python代码 | 点击:

在学习python的时候,

看到有些 代码中使用array[0][0] 来提取位置元素

不太明白。

动手实验了一下

import numpy as np
a = np.array([np.arange(12),np.arange(12,24)])
>>>print a
[[ 0 1 2 3 4 5 6 7 8 9 10 11]
 [12 13 14 15 16 17 18 19 20 21 22 23]]

>>>print a[0][6]
6

[0][6] means: get the 1st array and the 7th element.

But what's the difference of [0,6]??
their are the same answer!!

>>>print a[0,6]
6

您可能感兴趣的文章:

相关文章