1. 程式人生 > >python 判斷引數為Nonetype型別或空

python 判斷引數為Nonetype型別或空

Nonetype和空值是不一致的,可以理解為Nonetype為不存在這個引數,空值表示引數存在,但是值為空

判斷方式如下:

if hostip is None:
       print "no hostip,is nonetype"
elif hostip:
       print "hostip is not null"  
 else:
       print " hostip is null"