当前位置: 首页 > 图灵资讯 > 行业资讯> python如何判断字符是否大写

python如何判断字符是否大写

发布时间:2025-03-07 22:09:46

例子:

>>>str_1="HELLOPYTHON"#全大写
>>>str_2="HelloPYTHON"#大小写混合
>>>str_3="HelloPython"#首字母大写
>>>str_4="hellopython"#全小写

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平台,欢迎关注!

相关文章

如何让vim支持python3

如何让vim支持python3

2025-09-12
python2.7和3.6区别有哪些

python2.7和3.6区别有哪些

2025-09-12
python3有serial库吗

python3有serial库吗

2025-09-12
python中w、r表示什么意思

python中w、r表示什么意思

2025-09-12
python中如何把list变成字符串

python中如何把list变成字符串

2025-09-12
python命名空间是什么

python命名空间是什么

2025-09-12