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

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. java之常用正则表达式

    http://www.cnblogs.com/helloczh/articles/1648029.html http://wenku.baidu.com/link?url=gLcsovVfQqRTVa ...

  2. linux之scp

    传输文件夹 scp -r -P 目标端口号 文件夹名 目标用户名@目标服务器地址:目标存放地址 传输文件夹 scp -P 目标端口号 文件名 目标用户名@目标服务器地址:目标存放地址

  3. STM32-USB那点事

    STM32 USB那点事1 USB那点事2 - Custom HID例子程序解疑 USB那点事3 -使用端口2作为custom HID的传输 USB那点事5之USB通信出错 USB那点事6传输要素 S ...

  4. Chapter5 – 碰撞检测

    主人公能够放子弹了,虽然子弹看起来很美,但是怎么样来打到妖怪? 在这一章我们介绍一下最简单的碰撞检测方法去实现它. 首先第一个,我们有必要保存每个妖怪和子弹的指针,来够追踪他们的位置. 在这个游戏中我 ...

  5. IO文件

    在Windows下的路径分隔符和Linux下的路径分隔符是不一样的,当直接使用绝对路径时,跨平台会暴出“No such file or diretory”的异常. Separator: 比如说要在te ...

  6. 报错:Can't bind to local 8647 for debugger

    修改8600为8601,并且勾上Use ADBHOST

  7. Djanto static静态文件配置

    django的settings中包含三个static相关设置项: STATIC_ROOT STATIC_URL STATICFILES_DIRS   STATIC_URL 好理解,就是映射到静态文件的 ...

  8. WebGIS中通过行列号来换算出多种瓦片的URL 之离线地图(转载)

    WebGIS中通过行列号来换算出多种瓦片的URL 之离线地图 1.前言 在前面我花了两个篇幅来讲解行列号的获取,也解释了为什么要获取行列号.在这一章,我将把常见的几种请求瓦片时的URL样式罗列出来,并 ...

  9. Failed to install *.apk on device 'emulator-5554': timeout

    错误提示: Failed to install helloworld.apk on device 'emulator-5554': timeout 或者 the user data image is ...

  10. 2.13.1. 对结果排序(Core Data 应用程序实践指南)

    传递NSSortDescriptor给NSFetchRequest进行排序.示例如下,修改demo方法: NSSortDescriptor *sort = [NSSortDescriptor sort ...