def isNaNo(sth):
'''
NaN或None返回True,其他情况返回Flase
'''
if not sth:
return True
if isinstance(sth, float):
if np.isnan(sth):
return True
return False
if __name__ == '__main__':
import numpy as np
str_no = np.nan
flag = isNaNo(str_no)
print(flag)