numpy.obj2sctype()函數返回對象的標量dtype或等效於NumPy的Python類型。
用法: numpy.obj2sctype(rep, default = None)
參數:
rep:[any]返回類型的對象。
default:[任何,可選]如果給定,則為無法確定類型的對象返回此值。如果未給出,則不為那些對象返回None。
返回:[dtype或Python type]返回rep的數據類型。
代碼1:
# Python program explaining
# numpy.obj2sctype() function
# importing numpy as geek
import numpy as geek
gfg = geek.obj2sctype(geek.float64)
print (gfg)
輸出:
class 'numpy.float64'
代碼2:
# Python program explaining
# numpy.obj2sctype() function
# importing numpy as geek
import numpy as geek
gfg = geek.obj2sctype(geek.array([1.j]))
print (gfg)
輸出:
class 'numpy.complex128'
相關用法
- Python Wand function()用法及代碼示例
- Python now()用法及代碼示例
- Python id()用法及代碼示例
- Python tell()用法及代碼示例
- Python sum()用法及代碼示例
- Python str()用法及代碼示例
- Python cmp()用法及代碼示例
- Python ord()用法及代碼示例
- Python dir()用法及代碼示例
- Python hex()用法及代碼示例
- Python int()用法及代碼示例
- Python map()用法及代碼示例
- Python oct()用法及代碼示例
- Python math.sin()用法及代碼示例
- Python bytearray()用法及代碼示例
- Python math.tan()用法及代碼示例
注:本文由純淨天空篩選整理自sanjoy_62大神的英文原創作品 numpy.obj2sctype() function – Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。