Numpy 的 isscalar(~)
方法检查提供的参数是否为标量。
请注意,数字、字符串、np.inf
和 np.NaN
都是 Numpy 中的标量。
参数
1. num
| any
输入对象。
返回值
返回单个布尔值,其中 True
表示 num
是标量。
例子
基本用法
a = np.array([2])
np.isscalar(a)
False
np.isscalar(5)
True
np.isscalar(np.inf)
True
np.isscalar(np.NaN)
True
相关用法
- Python issubclass()用法及代码示例
- Python issubset()用法及代码示例
- Python issuperset()用法及代码示例
- Python string isspace()用法及代码示例
- Python isinstance方法用法及代码示例
- Python string isidentifier()用法及代码示例
- Python calendar isleap()用法及代码示例
- Python math isclose()用法及代码示例
- Python NumPy isalnum方法用法及代码示例
- Python NumPy isnat方法用法及代码示例
- Python string isupper()用法及代码示例
- Python string isalnum()用法及代码示例
- Python Pandas isnull方法用法及代码示例
- Python isdisjoint()用法及代码示例
- Python NumPy isposinf方法用法及代码示例
- Python NumPy isreal方法用法及代码示例
- Python string istitle()用法及代码示例
- Python NumPy isclose方法用法及代码示例
- Python math isnan()用法及代码示例
- Python NumPy iscomplexobj方法用法及代码示例
- Python string isalpha()用法及代码示例
- Python NumPy isnumeric方法用法及代码示例
- Python NumPy isrealobj方法用法及代码示例
- Python NumPy isfinite方法用法及代码示例
- Python string isdigit()用法及代码示例
注:本文由纯净天空筛选整理自Isshin Inada大神的英文原创作品 NumPy | isscalar method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。