借助sympy.is_number方法,我们可以检查element是否为数字,如果通过使用找到数字,它将返回一个布尔值sympy.is_number方法。
用法:sympy.is_number
返回:Return a boolean value if number is found.
范例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)输出:
True
范例2:
# import sympy 
from sympy import * 
  
x, y = symbols('x y') 
  
# Use sympy.is_number method 
gfg = sin(x).is_number 
     
print(gfg)输出:
False
相关用法
- Python os.dup()用法及代码示例
 - Python set()用法及代码示例
 - Python next()用法及代码示例
 - Python sys.getrecursionlimit()用法及代码示例
 - Python PIL eval()用法及代码示例
 - Python sympy.rf()用法及代码示例
 - Python os.waitid()用法及代码示例
 - Python os.WIFEXITED()用法及代码示例
 - Python os.scandir()用法及代码示例
 - Python PIL getpalette()用法及代码示例
 - Python sympy.ff()用法及代码示例
 - Python Decimal max()用法及代码示例
 - Python sympy.nT()用法及代码示例
 - Python os.sync()用法及代码示例
 
注:本文由纯净天空筛选整理自Jitender_1998大神的英文原创作品 Python | sympy.is_number method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
