📜  numpy.common_type()函数Python

📅  最后修改于: 2022-05-13 01:54:34.443000             🧑  作者: Mango

numpy.common_type()函数Python

numpy.common_type()函数返回输入数组共有的标量类型。

代码#1:

# Python program explaining
# numpy.common_type() function
          
# importing numpy as geek 
import numpy as geek 
      
gfg = geek.common_type(geek.arange(2, dtype = geek.float32))
    
print (gfg)

输出 :

class 'numpy.float32'


代码#2:

# Python program explaining
# numpy.common_type() function
          
# importing numpy as geek 
import numpy as geek 
      
gfg = geek.common_type(geek.arange(2, dtype = geek.float32), geek.arange(2))
    
print (gfg)

输出 :

class 'numpy.float64'