字符串中返回bool类型的函数集合
isspace
功能:
用法:
booltype = string.isspace() -> 无参数可传 ,返回一个布尔类型
注意:
- 由空格组成的字符串,不是空字符串 : “'!=‘’'
istitile
功能:
用法
booltype = String.istitle() -> 无参数可传, 返回一个布尔类型
注意:
isupper与islower
功能:
isupper判断字符串中的字母是否都是大写
islower判断字符串中的字母是否都是小写
用法:
booltype = string.isupper() -> 无参数可传 , 返回一个布尔类型
booltype = string,islower() ->无参数可传 ,返回一个布尔类型
注意:
join与split 稍后见
代码
title = '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.istitle())
print(upper_str_02.istitle())
print('isuppr', upper_str.isupper())
print(lower_str.isupper())
print('islower', lower_str.islower())
print(not_empty.isspace())