python之字符串详解2
逻辑判断字符串类型,返回布尔值
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的更多相关文章
- python 03 字符串详解
1.制表符 \t str.expandtabs(20) 可相当于表格 2.def isalpha(self) 判断是否值包含字母(汉字也为真),不包含数字 3.def isdecimal(se ...
- Python之字符串详解1
1. 查看类型 name = 'allen' print(type(name)) #查看类型 <class 'str'> #类型为str age = 19 print(type(name) ...
- Python变量和字符串详解
Python变量和字符串详解 几个月前,我开始学习个人形象管理,从发型.妆容.服饰到仪表仪态,都开始做全新改造,在塑造个人风格时,最基础的是先了解自己属于哪种风格,然后找到参考对象去模仿,可以是自己欣 ...
- python time模块详解
python time模块详解 转自:http://blog.csdn.net/kiki113/article/details/4033017 python 的内嵌time模板翻译及说明 一.简介 ...
- 【python进阶】详解元类及其应用2
前言 在上一篇文章[python进阶]详解元类及其应用1中,我们提到了关于元类的一些前置知识,介绍了类对象,动态创建类,使用type创建类,这一节我们将继续接着上文来讲~~~ 5.使⽤type创建带有 ...
- Python开发技术详解PDF
Python开发技术详解(高清版)PDF 百度网盘 链接:https://pan.baidu.com/s/1F5J9mFfHKgwhkC5KuPd0Pw 提取码:xxy3 复制这段内容后打开百度网盘手 ...
- python之数据类型详解
python之数据类型详解 二.列表list (可以存储多个值)(列表内数字不需要加引号) sort s1=[','!'] # s1.sort() # print(s1) -->['!', ' ...
- (转)python collections模块详解
python collections模块详解 原文:http://www.cnblogs.com/dahu-daqing/p/7040490.html 1.模块简介 collections包含了一些特 ...
- Python之print详解
Python之print详解 http://www.jb51.net/article/55768.htm print的一些基本用法,在前面的讲述中也涉及一些,本讲是在复习的基础上,尽量再多点内容. ...
随机推荐
- CSS3 Media Queries 详解
说起CSS3的新特性,就不得不提到 Media Queries .最近 Max Design 更新的一个泛读列表里,赫然就有关于 Media Queries 的文章.同时位列其中的也有前天我刚刚翻译的 ...
- 【BZOJ 1367】 1367: [Baltic2004]sequence (可并堆-左偏树)
1367: [Baltic2004]sequence Description Input Output 一个整数R Sample Input 7 9 4 8 20 14 15 18 Sample Ou ...
- 修改替换/system/framework/framework.jar后重启手机为何没有效果?
自Android 5.0开始android默认使用art(Android4.4开始有实验性质的art),取代原来的Dalvik, art会加载boot.art和boot.oat两个文件(静态编译优化, ...
- 51驱动LCD12864
LCD12864与LCD1602最大的区别在于LCD12864可以显示汉字,同时也可以拿来画图;当然,作为图形显示不推荐lcd12864,推荐NOKIA5110 12864引脚基本和1602的引脚吻合 ...
- Xcode的版本问题
1. 已经安装了Xcode6,如何再安装Xcode5,并使两者共存? 2. Xcode6升级到Xcode7 适配问题 3. XCODE6中使用iOS7 SDK的方法: 从XCODE 5的目录中: /A ...
- 全方位分析Objcetive-C Runtime
本文详细整理了 Cocoa 的 Runtime 系统的知识,它使得 Objective-C 如虎添翼,具备了灵活的动态特性,使这门古老的语言焕发生机.主要内容如下: 引言 简介 与Runtime交互 ...
- thinkphp所有参数配置
/* 项目设定 */ 'APP_DEBUG' => false, // 是否开启调试模式 'APP_DOMAIN_DEPLOY' => false, // 是否使用独立域名部署项目 'AP ...
- VB.Net隐式转换和显式转换的方法(转)
VB.Net隐式转换和显式转换的方法(转) “隐式转换”不需要源代码中的任何特殊语法.在下面的示例中,在将 k 的值赋给 q 之前,Visual Basic 将该值隐式转换成单精度浮点值. Dim ...
- Java的三种代理模式
Java的三种代理模式 1.代理模式 代理(Proxy)是一种设计模式,提供了对目标对象另外的访问方式;即通过代理对象访问目标对象.这样做的好处是:可以在目标对象实现的基础上,增强额外的功能操作,即扩 ...
- 笔记整理——C语言-http-1
http 传输原理及格式 - friping - ITeye技术网站 - Google Chrome (2013/4/1 14:02:36) http 传输原理及格式 博客分类: 其他 应用服务器浏览 ...