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的一些基本用法,在前面的讲述中也涉及一些,本讲是在复习的基础上,尽量再多点内容. ...
随机推荐
- function $(id){ return document.getElementById(id); }导致所有的js不能用解决办法。。。。
function $(id){ return document.getElementById(id); } document.getElementById(id) 是获得id这个元素的. 相当于定义了 ...
- rapidjson 使用教程
在cocos2d-x引入了rapidjson,它处理速度比其他的json库快,反正不管了,我们这边只是学习下如何使用.rapidjson官方网址: https://code.google.com/p/ ...
- Apache的Directory配置指南
使用<Directory>… </Directory>设置指定目录的访问权限,其中可包含:Options.Allow.Override.Order.Allow.Deny.Req ...
- S3C2440硬件连接解析
S3c2440是三星公司推出的一款基于ARM920T的处理器,采用ARM内核,不同于单片机,无片上rom与ram,必须搭配相应的外围电路进行使用,现在,让我们从零开始进行这一块MCU的学习,为了入门简 ...
- linux 更换yum源
1.进入存放源配置的文件夹 cd /etc/yum.repos.d 2.备份默认源 mv ./CentOS-Base.repo ./CentOS-Base.repo.bak 3.使用wget下载163 ...
- C语言-for循环
for循环是C语言中的循环语句之一,它的一般形式为for(初值,条件表达式,步长){语句};初值通常是一个赋值语句, 它用来给循环控制变量赋初值: 条件表达式是一个关系表达式, 它决定什么时候退出循环 ...
- c++初学(电梯实验加强版)
Elevator.h class Elevator{public: Elevator(); ~Elevator(); void getNowNum(); void Se ...
- .net学习路线
http://www.cnblogs.com/huangmeimujin/archive/2011/08/08/2131242.html http://jingyan.baidu.com/articl ...
- Grid (read-only) objects and methods (client-side reference)获取子表单对象的一些方法 Crm 2016
https://msdn.microsoft.com/en-us/library/dn932126.aspx#BKMK_GridControl Updated: November 29, 2016 A ...
- ajax 跨域了 cors
<?php /** * Author: humanhuang * Date: 13-12-17 */ header('Access-Control-Allow-Origin:*'); heade ...