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


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

numpy.sctype2char()函數返回標量dtype的字符串表示形式。

用法: numpy.sctype2char(sctype)

參數:
sctype:[標量dtype或對象]如果sctype是標量dtype,則返回相應的字符串字符。如果是對象,則sctype2char嘗試推斷其標量類型,然後返回相應的字符串字符。
返回:[str]與標量類型相對應的字符串字符。

代碼1:

# Python program explaining 
# numpy.sctype2char() function 
            
# importing numpy as geek  
import numpy as geek  
  
x = geek.array([1., 2-1.j]) 
  
gfg = geek.sctype2char(x) 
  
print (gfg)

輸出:

D


代碼2:

# Python program explaining 
# numpy.sctype2char() function 
            
# importing numpy as geek  
import numpy as geek  
  
gfg = geek.sctype2char(list) 
  
print (gfg)

輸出:

0

相關用法


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