Python 2.7.9 Demo

#coding=utf-8
#!/usr/bin/python

str1 = None;
str2 = '';
str3 = ' ';

if str1 == None :
    print("str1 is none.");
else :
    print("str1 is not none.");

if str2 == None :
    print("str2 is none.");
else :
    print("str2 is not none.");

if str2 == None or len(str2) == 0 :
    print("str2 is none.");
else :
    print("str2 is not none.");

if str3 == None or len(str3.strip()) == 0 :
    print("str3 is none.");
else :
    print("str3 is not none.");
原文地址:https://www.cnblogs.com/nick-huang/p/4617273.html