#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 Demo - 005.字符串判空的更多相关文章

  1. Shell脚本中字符串判空:使用-z 字符串长度为0时,为真,-n字符串长度不为0,为真。这两个都不靠谱【转】

    最近发现使用  -z   和  -n  来判断字符串判空,或不空时,很不靠谱. 使用下面的方法最可靠: if [ "x${value}" == "x" ]    ...

  2. shell 字符串判空

    2021-09-01 1. 字符串判空主要用到两个参数 -z 判断字符串为空否 -n 判断字符串不为空 2. 实例 #!/bin/bash PID=`date` if [ -z "$PID& ...

  3. 前端js判空处理,js字符串判空,js数组判空

    1.字符串 在 js 中,字符串为空会有这么几种形式,"",null,undefined,如果在已知变量为空串的情况下可以直接采用 if (string.length == 0) ...

  4. StringUtils中 isNotEmpty 和isNotBlank的区别【java字符串判空】

    isNotEmpty(str)等价于 str != null && str.length > 0 isNotBlank(str) 等价于 str != null &&am ...

  5. mybatis注解版in查询、字符串判空模糊匹配 、批量插入、插入返回主键

    IN查询 @Select({"<script> " + " select * "+ " from business_threat bt \ ...

  6. shell字符串判空

    主要用到两个命令 -n  -z if [ -n "$PID" ]; then echo "PID is not empty" fi if[ -z "$ ...

  7. 一题多解(一) —— list(Python)判空(以及 is 与 == 的区别)

    >> l = [] 1. == >> l == [] True 2. not >> not l True 3. 注意 is 与 == 的区别 >> l ...

  8. Python黑帽编程2.3 字符串、列表、元组、字典和集合

    Python黑帽编程2.3  字符串.列表.元组.字典和集合 本节要介绍的是Python里面常用的几种数据结构.通常情况下,声明一个变量只保存一个值是远远不够的,我们需要将一组或多组数据进行存储.查询 ...

  9. appium+Python真机运行测试demo的方法

    appium+Python真机运行测试demo的方法 一,    打开手机的USB调试模式 二,    连接手机到电脑 将手机用数据线连接到电脑,并授权USB调试模式.查看连接的效果,在cmd下运行命 ...

随机推荐

  1. yum安装MangoDB

    1:操作系统信息 2:yum命令查看MongoDB的包信息 3:配置yum源 #vi /etc/yum.repos.d/10gen.repo 4:查看mongoDB的服务器包的信息 5:安装Mongo ...

  2. libevent个人理解

    1.利用了前置声明来在c语言的基础上进行封装操作.即在include目录下防止event.h等头文件,在这些头文件中只暴露struct的声明却不暴露其定义,对于如event_base等结构的操作均使用 ...

  3. wso2esb安装及helloworld

    1.系统环境 Ubuntu12.04    192.168.0.97    root/password找管理员 Ubuntu12.04    192.168.0.99    root/password ...

  4. EXCEPTION-javaBean

      CreateTime--2016年11月24日14:29:43Author:Marydon 声明:异常类文章主要是记录了我遇到的异常信息及解决方案,解决方案大部分都是百度解决的,(这里只是针对我遇 ...

  5. eclipse to avoid the message, disable the...

      标题 CreateTime--2018年5月9日10:38:15 Author:Marydon 1.问题描述 2.问题解析 这是因为eclipse的智能提示超时引起的,将超时间调大即可,如:200 ...

  6. DIV布局之position详解

    相对定位和绝对定位 定位标签:position 包含属性:relative(相对) absolute(绝对) 1.position:relative; 如果对一个元素进行相对定位,首先它将出现在它所在 ...

  7. PHP中curl的使用

    cURL 函数 curl_close — 关闭一个cURL会话 curl_copy_handle — 复制一个cURL句柄和它的所有选项 curl_errno — 返回最后一次的错误号 curl_er ...

  8. HDUOJ-------2844Coins

    Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  9. eclipse代码格式化设置

    http://www.cnblogs.com/zhxiaomiao/archive/2010/06/19/1760995.html java---code style ---formatter 首先新 ...

  10. SecureCRT 详细使用教程和技巧

    SecureCRT 常用技巧 0.在secureCRT里切换不同的窗口:ctrl+tab.    复制:[ctrl] + [shift] + c    粘贴:[ctrl] + [shift] + v  ...