numpy

1.numpy中的numpy.ndarray可以接受一个list或者一个ndarray为参数进行索引:
a=np.arange(12,100,12,'f')
print(a[[1,2,3]])
------
[ 24.  36.  48.]

2.
a=np.arange(12,100,12,'f')
print(a>24)
print(a[a>24])
print(a[[False,False,True,True,True,True,True,True]])
-------
[False False  True  True  True  True  True  True]
[ 36.  48.  60.  72.  84.  96.]
[ 36.  48.  60.  72.  84.  96.]

评论

此博客中的热门博文

225 Implement Stack using Queues

232. Implement Queue using Stacks

20. Valid Parentheses