numpy.promote_types()函數是一個對稱函數,它返回具有最小大小和最小標量類型的數據類型,可以將類型1和類型2都安全地轉換為該數據類型。返回的數據類型始終以本機字節順序。
用法: numpy.promote_types(type1, type2)
參數:
type1:[dtype或dtype說明符]第一個數據類型。
type2:[dtype或dtype說明符]第二種數據類型。
返回:[dtype]返回提升的數據類型。
代碼1:
# Python program explaining
# numpy.promote_types() function
# importing numpy as geek
import numpy as geek
gfg = geek.promote_types('f4', 'i8')
print (gfg)
輸出:
float64
代碼2:
# Python program explaining
# numpy.promote_types() function
# importing numpy as geek
import numpy as geek
gfg = geek.promote_types('>i8', '<c8')
print (gfg)
輸出:
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.promote_types() function – Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。