擅长:python、mysql、java
<p>Numpy有一个类似于类层次结构的数据类型层次结构(标量类型实际上有一个真实的类层次结构,它反映了数据类型层次结构)。可以使用<code>np.issubdtype(some_dtype, np.integer)</code>来测试数据类型是否为整数数据类型。请注意,与大多数使用dtype的函数一样,<code>np.issubdtype()</code>将其参数转换为dtype,因此可以使用任何可以通过<code>np.dtype()</code>构造函数生成dtype的函数。</p>
<p><a href="http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#specifying-and-constructing-data-types" rel="noreferrer">http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#specifying-and-constructing-data-types</a></p>
<pre><code>>>> import numpy as np
>>> np.issubdtype(np.int32, np.integer)
True
>>> np.issubdtype(np.float32, np.integer)
False
>>> np.issubdtype(np.complex64, np.integer)
False
>>> np.issubdtype(np.uint8, np.integer)
True
>>> np.issubdtype(np.bool, np.integer)
False
>>> np.issubdtype(np.void, np.integer)
False
</code></pre>
<p>在未来的numpy版本中,我们将确保标量类型注册到适当的<code>numbers</code>ABCs。</p>