码迷,mamicode.com
首页 > 编程语言 > 详细

Python 2.7.9 - 005.字符串判空

时间:2015-07-02 22:33:29      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

 

#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.");

 

Python 2.7.9 - 005.字符串判空

标签:

原文地址:http://www.cnblogs.com/nick-huang/p/4617273.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!