简体   繁体   中英

Python numpy multidimensional array indexing

I have a problem trying to indexing elements in numpy array

import numpy as np

a=np.zeros([10,6,1,1],dtype=np.float32)

And I want to do something like that, eg print(a[2,3,1,1])

but it gives wrong indexing

Indexes are zero-based.

If you create an array of size 10, you index the elements as 0-9

>>> import numpy as np
>>> a=np.zeros([10,6,1,1],dtype=np.float32)
>>> print a[1, 2, 0, 0]
0.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM