例如:(推荐学习: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教程栏目进行学习!
Copyright © 2019- hids.cn 版权所有 赣ICP备2024042780号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务