逻辑判断字符串类型,返回布尔值

1. islower

描述:判断所有字符是否为小写

语法:

    def islower(self): # real signature unknown; restored from __doc__
"""
S.islower() -> bool Return True if all cased characters in S are lowercase and there is
at least one cased character in S, False otherwise.
"""
return False

样例:

name='allen'
result=name.islower() #判断字符都为小写
print(result) True #显示结果

2. isupper

描述:判断所有字符是否为大写

语法:

    def isupper(self): # real signature unknown; restored from __doc__
"""
S.isupper() -> bool Return True if all cased characters in S are uppercase and there is
at least one cased character in S, False otherwise.
"""
return False

样例:

name='allen'
result=name.isupper() #判断所有字符为大写
print(result) False #显示结果

3. istitle

描述:判断是否为title类型,即第一个字符为大写,其他为小写

语法:

    def istitle(self): # real signature unknown; restored from __doc__
"""
S.istitle() -> bool Return True if S is a titlecased string and there is at least one
character in S, i.e. upper- and titlecase characters may only
follow uncased characters and lowercase characters only cased ones.
Return False otherwise.
"""
return False

样例:

name='Allen'
result=name.istitle() #判断是否为title类型的字符串
print(result) True #显示结果

4. isalpha

描述:判断所有字符是否为字母

语法:

  def isalnum(self): # real signature unknown; restored from __doc__
"""
S.isalnum() -> bool Return True if all characters in S are alphanumeric
and there is at least one character in S, False otherwise.
"""
return False

样例:

name = 'allen'
result=name.isalpha() #判断所有字符为字母
print(result) True #显示结果

isalpha

5. isdigit

描述:判断所有字符是否为数字

语法:

    def isdigit(self): # real signature unknown; restored from __doc__
"""
S.isdigit() -> bool Return True if all characters in S are digits
and there is at least one character in S, False otherwise.
"""
return False

样例:

name = ''
result=name.isdigit() #判断所有字符为数字
print(result) True #显示结果 name = '123abc'
result=name.isdigit() #判断所有字符为数字
print(result) False #显示结果

isdigit

6. isdecimal

描述:判断所有字符是否是十进制数

语法:

    def isdecimal(self): # real signature unknown; restored from __doc__
"""
S.isdecimal() -> bool Return True if there are only decimal characters in S,
False otherwise.
"""
return False

样例:

name = ''
result=name.isdecimal() #判断所有字符是否是十进制
print(result) True #显示结果 name = '123abc'
result=name.isdecimal() #判断所有字符是否是十进制
print(result) False #显示结果

decimal

 

python之字符串详解2的更多相关文章

  1. python 03 字符串详解

    1.制表符 \t str.expandtabs(20) 可相当于表格 2.def   isalpha(self) 判断是否值包含字母(汉字也为真),不包含数字 3.def   isdecimal(se ...

  2. Python之字符串详解1

    1. 查看类型 name = 'allen' print(type(name)) #查看类型 <class 'str'> #类型为str age = 19 print(type(name) ...

  3. Python变量和字符串详解

    Python变量和字符串详解 几个月前,我开始学习个人形象管理,从发型.妆容.服饰到仪表仪态,都开始做全新改造,在塑造个人风格时,最基础的是先了解自己属于哪种风格,然后找到参考对象去模仿,可以是自己欣 ...

  4. python time模块详解

    python time模块详解 转自:http://blog.csdn.net/kiki113/article/details/4033017 python 的内嵌time模板翻译及说明  一.简介 ...

  5. 【python进阶】详解元类及其应用2

    前言 在上一篇文章[python进阶]详解元类及其应用1中,我们提到了关于元类的一些前置知识,介绍了类对象,动态创建类,使用type创建类,这一节我们将继续接着上文来讲~~~ 5.使⽤type创建带有 ...

  6. Python开发技术详解PDF

    Python开发技术详解(高清版)PDF 百度网盘 链接:https://pan.baidu.com/s/1F5J9mFfHKgwhkC5KuPd0Pw 提取码:xxy3 复制这段内容后打开百度网盘手 ...

  7. python之数据类型详解

    python之数据类型详解 二.列表list  (可以存储多个值)(列表内数字不需要加引号) sort s1=[','!'] # s1.sort() # print(s1) -->['!', ' ...

  8. (转)python collections模块详解

    python collections模块详解 原文:http://www.cnblogs.com/dahu-daqing/p/7040490.html 1.模块简介 collections包含了一些特 ...

  9. Python之print详解

    Python之print详解 http://www.jb51.net/article/55768.htm   print的一些基本用法,在前面的讲述中也涉及一些,本讲是在复习的基础上,尽量再多点内容. ...

随机推荐

  1. CABasicAnimation 基本动画

    几个可以用来实现热门APP应用PATH中menu效果的几个方法 +(CABasicAnimation *)opacityForever_Animation:(float)time //永久闪烁的动画 ...

  2. android 点滴记录

    1.AndroidM环境下,在framework层添加代码会对jar包的package name进行检查,并提示”unknown package name of class file”怎么解决? 产生 ...

  3. 8、手把手教你Extjs5(八)自定义菜单2

    这一节来定义另外三种类型的菜单类.首先定义菜单按钮类.文件放于app/view/main/region目录下面,文件名为ButtonMainMenu.js. /** * 显示在顶部的按钮菜单,可以切换 ...

  4. (简单) HDU 1698 Just a Hook , 线段树+区间更新。

    Description: In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of ...

  5. 第一章 Slenium2-Java 自动化测试基础

    都是一些最基础的知识点. 一:软件测试分类 1)单元测试:单元测试(或模块测试)是对程序中的单个子程序或具有独立功能的代码段进行测试的过程.2)集成测试:集成测试是在单元测试的基础上,先通过单元模块组 ...

  6. CSS重设(reset)

    在当今网页设计/开发实践中,使用CSS来为语义化的(X)HTML标记添加样式风格是重要的关键.在设计师们的梦想中都存在着这样的一个完美世界:所有的浏览器都能够理解和适用多有CSS规则,并且呈现相同的视 ...

  7. linux java.net.UnknownHostException异常

    异常场景: 使用InetAddress.getLocalHost().getAddress(); 获取address byte数组.在windows上开发的时候,没有问题.部署到linux时报 jav ...

  8. 无锁同步-JAVA之Volatile、Atomic和CAS

    1.概要 本文是无锁同步系列文章的第二篇,主要探讨JAVA中的原子操作,以及如何进行无锁同步. 关于JAVA中的原子操作,我们很容易想到的是Volatile变量.java.util.concurren ...

  9. 如何使用python timeit模块使用实践

    其实平时使用测试应用运行时间的情况 细算一下还真的很少.很久没有做性能优化的工作,不管是cProfile还是timeit模块都已经生疏了很久没有使用,我在以前的文章里面有提到过cPfile的性能测试使 ...

  10. cpsr当前程序状态寄存器

    详解CPSR寄存器(ls_core) (2012-10-11 17:29:47) 转载▼ 标签: arm920t寄存器 cpsr cpu工作原理 分类: 第四章-踏入嵌入式领域之ARM 在介绍CPSR ...