sam*_*sam 11 python floating-point numpy
我有一个号码
例如
a = 1.22373
type(a) is float
Run Code Online (Sandbox Code Playgroud)
同样明智的我想找到一个数字
float64
Run Code Online (Sandbox Code Playgroud)
或不.
我怎么会发现使用python或numpy?
ndp*_*dpu 29
使用isinstance:
>>> f = numpy.float64(1.4)
>>> isinstance(f, numpy.float64)
True
>>> isinstance(f, float)
True
Run Code Online (Sandbox Code Playgroud)
numpy.float64继承自python native float类型.那是因为它既浮动又浮动64(@Bakuriu thx指出).但是如果你要检查float64类型的python float实例变量,你会得到False
结果:
>>> f = 1.4
>>> isinstance(f, numpy.float64)
False
>>> isinstance(f, float)
True
Run Code Online (Sandbox Code Playgroud)