import numpy as np
def isNaNo(sth):
'''
NaN、None或者空字符串返回True,其他情况返回False
'''
if not sth:
return True
if isinstance(sth, float):
if np.isnan(sth):
return True
return False
if __name__ == '__main__':
str_no = np.nan
flag = isNaNo(str_no)
print(flag)
python判断值是否为NaN、None或者空字符串
于 2022-02-15 10:01:42 首次发布