Python 的 str.istitle()
方法返回 boolean
指示字符串是否采用標題大小寫且至少包含一個字符。
注意
Titlecased 字符串是大寫字符隻能跟在非大小寫字符後麵,小寫字符隻能跟在大小寫字符後麵。示例:這是一個標題字符串
參數
無參數。
返回值
單個 boolean
指示字符串是否采用標題大小寫且至少包含一個字符。
例子
基本用法
檢查 'This is not a titlecased string'
是否是標題字符串:
x = 'This is not a titlecased string'
x.istitle()
False
在此示例中,小寫字符後麵跟著非大小寫字符(例如空格),因此該字符串不是標題大小寫的。
檢查 'This Is A Titlecased String'
是否是標題字符串:
y = 'This Is A Titlecased String'
y.istitle()
True
相關用法
- Python String istitle()用法及代碼示例
- Python String isnumeric方法用法及代碼示例
- Python String isalnum()用法及代碼示例
- Python String isidentifier()用法及代碼示例
- Python String isprintable()用法及代碼示例
- Python String isalnum方法用法及代碼示例
- Python String isalpha方法用法及代碼示例
- Python String isspace()用法及代碼示例
- Python String isspace方法用法及代碼示例
- Python String isprintable方法用法及代碼示例
- Python String isdecimal()用法及代碼示例
- Python String isdigit方法用法及代碼示例
- Python String isdigit()用法及代碼示例
- Python String isupper()用法及代碼示例
- Python String isalpha()用法及代碼示例
- Python String isdecimal方法用法及代碼示例
- Python String islower方法用法及代碼示例
- Python String islower()用法及代碼示例
- Python String isascii方法用法及代碼示例
- Python String isnumeric()用法及代碼示例
- Python String isidentifier方法用法及代碼示例
- Python String isupper方法用法及代碼示例
- Python String index()用法及代碼示例
- Python String index方法用法及代碼示例
- Python String count方法用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 Python String | istitle method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。