Python 的 str.isupper(~)
方法返回 boolean
指示字符串中的所有大小寫字符是否均為大寫。請注意,當字符串僅包含特殊字符時,返回 False
。
參數
無參數。
返回值
boolean
指示字符串中的所有大小寫字符是否均為大寫。
例子
基本用法
當所有大小寫字符都不是大寫時:
x = 'SkyTowner'
x.isupper()
False
當所有大小寫字符均為大寫時:
y = 'SKYTOWNER'
y.isupper()
True
非大小寫字符
當所有字符都是特殊字符或數字時:
z = '123'
z.isupper()
False
當字符串是特殊字符和大寫字符的混合時:
a = '123A'
a.isupper()
True
請注意,isupper()
方法僅檢查所有大小寫字符是否均為大寫,而忽略數字等非大小寫字符。
相關用法
- Python String isupper()用法及代碼示例
- Python String isnumeric方法用法及代碼示例
- Python String isalnum()用法及代碼示例
- Python String isidentifier()用法及代碼示例
- Python String isprintable()用法及代碼示例
- Python String isalnum方法用法及代碼示例
- Python String isalpha方法用法及代碼示例
- Python String isspace()用法及代碼示例
- Python String istitle方法用法及代碼示例
- Python String isspace方法用法及代碼示例
- Python String isprintable方法用法及代碼示例
- Python String isdecimal()用法及代碼示例
- Python String isdigit方法用法及代碼示例
- Python String isdigit()用法及代碼示例
- Python String isalpha()用法及代碼示例
- Python String isdecimal方法用法及代碼示例
- Python String istitle()用法及代碼示例
- Python String islower方法用法及代碼示例
- Python String islower()用法及代碼示例
- Python String isascii方法用法及代碼示例
- Python String isnumeric()用法及代碼示例
- Python String isidentifier方法用法及代碼示例
- Python String index()用法及代碼示例
- Python String index方法用法及代碼示例
- Python String count方法用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 Python String | isupper method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。