str.isspace()
如果字符串中只有空白字符且至少有一个字符则返回 True ,否则返回 False 。
空白 字符是指在 Unicode 字符数据库 (参见 unicodedata) 中主要类别为 Zs (“Separator, space”) 或所属双向类为 WS, B 或 S 的字符。
str.istitle()
如果字符串中至少有一个字符且为标题字符串则返回 True ,例如大写字符之后只能带非大写字符而小写字符必须有大写字符打头。 否则返回 False 。
str.isupper()
如果字符串中至少有一个区分大小写的字符且此类字符均为大写则返回 True ,否则返回 False 。
str.islower()
如果字符串中至少有一个区分大小写的字符且此类字符均为小写则返回 True ,否则返回 False 。
# coding:gbktitle = 'Back Of China'
upper_str = 'PYTHON IS A GOOD CODE 哈哈!'
upper_str_02 = 'Python Is A Good Code'
lower_str = 'i love python 哈哈 !'
not_empty = '! !'print(title.istitle())
print(upper_str_02.istitle())print('isupper', upper_str.isupper())print('islower', lower_str.islower())print(not_empty.isspace())