📜  Python| sympy.is_number 方法

📅  最后修改于: 2022-05-13 01:54:45.784000             🧑  作者: Mango

Python| sympy.is_number 方法

借助sympy.is_number方法,我们可以检查元素是否为数字,如果使用sympy.is_number方法找到数字,它将返回一个布尔值。

示例 #1:
在这个例子中,我们可以看到通过使用sympy.is_number()方法,我们能够通过获取布尔值来检测数字。

# import sympy
from sympy import * 
  
x, y = symbols('x y')
  
# Use sympy.is_number method
gfg = cos(2).is_number
     
print(gfg)

输出 :

示例 #2:

# import sympy
from sympy import * 
  
x, y = symbols('x y')
  
# Use sympy.is_number method
gfg = sin(x).is_number
     
print(gfg)

输出 :