array python numpy
import numpy as np
ary=np.array([1, 2, 3, 4])
print(ary[0]) # 1
print(ary[2]) # 3
print(ary[::2]) # array([1, 3])
Nazário
import numpy as np
ary=np.array([1, 2, 3, 4])
print(ary[0]) # 1
print(ary[2]) # 3
print(ary[::2]) # array([1, 3])
# First mode, buffer is None:
>>> np.ndarray(shape=(2,2), dtype=float, order='F')
array([[0.0e+000, 0.0e+000], # random
[ nan, 2.5e-323]])
#Second mode:
>>> np.ndarray((2,), buffer=np.array([1,2,3]),
offset=np.int_().itemsize,
dtype=int) # offset = 1*itemsize, i.e. skip first element
array([2, 3])