借助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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
