numpy.mintypecode()函數返回可以將給定類型強製轉換為minimum-size類型的字符。
用法: numpy.mintypecode(typechars, typeset = ‘GDFgdf’, default = ‘d’)
參數:
typechars:[str或數組的列表]如果是字符串列表,則每個字符串應表示一個dtype。如果為數組,則使用數組dtype的字符表示。
typeset:[str或str的列表,可選]從中選擇返回字符的字符集。默認設置為“ GDFgdf”。
default:[str,可選]默認字符,如果typechars中的所有字符都不與typeset中的字符匹配,則返回此默認字符。
返回:[str]代表找到的minimum-size類型的字符。
代碼1:
# Python program explaining
# numpy.mintypecode() function
# importing numpy as geek
import numpy as geek
gfg = geek.mintypecode(['d', 'f', 'S'])
print (gfg)
輸出:
d
代碼2:
# Python program explaining
# numpy.mintypecode() function
# importing numpy as geek
import numpy as geek
x = geek.array([1.1, 2-1.j])
gfg = geek.mintypecode(x)
print (gfg)
輸出:
D
相關用法
- 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.mintypecode() function – Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。