當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python numpy.typename()用法及代碼示例

numpy.typename()函數返回給定數據類型代碼的描述。

用法: numpy.typename(char)

參數:
char:[str]數據類型代碼。
返回:[str]輸入數據類型代碼的描述。

代碼1:

# Python program explaining 
# numpy.typename() function 
            
# importing numpy as geek  
import numpy as geek  
  
typechars = ['?', 'O', 'b', 'd', 'g', 'f', 'i', 'h', 'l', 'q']  
  
for typechar in typechars:
    print(typechar, ':', geek.typename(typechar))

輸出:

? : bool
O : object
b : signed char
d : double precision
g : long precision
f : single precision
i : integer
h : short
l : long integer
q : long long integer


代碼2:

# Python program explaining 
# numpy.typename() function 
            
# importing numpy as geek  
import numpy as geek  
  
typechars = ['S1', 'B', 'D', 'G', 'F', 'I', 'H', 'L', 'Q', 'S', 'U', 'V']  
  
for typechar in typechars:
    print(typechar, ':', geek.typename(typechar))

輸出:

S1 : character
B : unsigned char
D : complex double precision
G : complex long double precision
F : complex single precision
I : unsigned integer
H : unsigned short
L : unsigned long integer
Q : unsigned long long integer
S : string
U : unicode
V : void

相關用法


注:本文由純淨天空篩選整理自sanjoy_62大神的英文原創作品 numpy.typename() function – Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。