How can I check for NaN values?

后端 未结 17 1897
盖世英雄少女心
盖世英雄少女心 2020-11-22 05:02

float(\'nan\') results in Nan (not a number). But how do I check for it? Should be very easy, but I cannot find it.

17条回答
  •  误落风尘
    2020-11-22 05:45

    Another method if you're stuck on <2.6, you don't have numpy, and you don't have IEEE 754 support:

    def isNaN(x):
        return str(x) == str(1e400*0)
    

提交回复
热议问题