您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

python用函数怎么判断大小写

2025/7/1 10:49:55发布19次查看
python提供了isupper(),islower(),istitle()方法用来判断字符串的大小写, 具体实例如下:
例如:(推荐学习:python视频教程)
>>> str_1 = hello python # 全大写>>> str_2 = hello python # 大小写混合>>> str_3 = hello python # 单词首字母大写>>> str_4 = hello python # 全小写
isupper() 判断是否全是大写
>>> str_1.isupper()true>>> str_2.isupper()false>>> str_3.isupper()false>>> str_4.isupper()false
islower()判断是否全是小写
>>> str_1.islower()false>>> str_2.islower()false>>> str_3.islower()false>>> str_4.islower()true
istitle()判断首字母是否大写, 其余的是否小写
>>> str_1.istitle()false>>> str_2.istitle()false>>> str_3.istitle()true>>> str_4.istitle()false
更多python相关技术文章,请访问python教程栏目进行学习!
以上就是python用函数怎么判断大小写的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product