1.删除空白符函数
lstrip();rstrip();strip();
语法类似,字符串序列.对应函数()

#lstrip():删除字符串左侧空白字符
str="    you everyone and yes and word and ok   "
str1=str.lstrip()
print(str1)  #you everyone and yes and word and ok
#rstrip() 删除字符串右侧空白字符
str2=str.rstrip()
print(str2)  #    you everyone and yes and word and ok
#strip():删除字符串两侧空白字符
str3=str.strip()
print(str3)  #you everyone and yes and word and ok

2.(填充)对齐函数
ljust();rjust();center();
语法类似,字符串序列.对应函数()

#ljust() 返回一个字符串左对齐,并使用指定字符(默认是空格)填充至对应长度的新字符串
#语法 字符串序列.ljust(长度,指定填充字符)
#rjust() 返回一个字符串右对齐,并使用指定字符(默认是空格)填充至对应长度的新字符串
#语法 字符串序列.just(长度,指定填充字符)
#center() 返回一个字符串居中对齐,并使用指定字符(默认是空格)填充至对应长度的新字符串
#语法 字符串序列.center(长度,指定填充字符)
sstr='abcde'
str4=sstr.ljust(9,'0')
print(str4)  #abcde0000
str5=sstr.ljust(9)
print(str5)  #abcde
str6=sstr.rjust(9,'1')
print(str6)  #1111abcde
str7=sstr.center(9,'.')

3.判断是否以指定字符串开头结尾的函数
startswith();endswith();

#startswith() 检查某字符串是否以指定字串开头,返回布尔型数据类型
#语法,字符串序列。startswith(字串,开始位置下标,结束位置下标)
#没有标明开始结束范围则默认整个字符串序列
strr="you everyone and yes and word and ok"
print(strr.startswith('you'))    #ture
print(strr.startswith('you',2,10))    #false
#endswith() 检查某字符串是否以指定字串结尾,返回布尔型数据类型
#语法,字符串序列。endswith(字串,开始位置下标,结束位置下标)
#没有标明开始结束范围则默认整个字符串序列
print(strr.endswith('ok'))   #ture
print(strr.endswith('ook'))  #false
print(strr.endswith('ok',2,10))  #false

4.判断字符串是否都是数字或字母或空格等
isalpha();isdigit();isalnum();isspace();

#isalpha()  判断是否字符串至少有一个字符且所有字符都是字母,返回布尔型数据
#语法  字符串序列.isalpha()
sttr='you1234'
print(sttr.isalpha())   #false
strr1='you'
print(strr1.isalpha())    #ture
#isdigit()  判断是否字符串只包含数字,返回布尔型数据
#语法  字符串序列.isdigit()
strr2='you12'
print(strr2.isdigit())  #false
strr3='123'
print(strr3.isdigit())  #ture
#isalnum()  判断是否字符串至少有一个字符且所有字符都是字母或者数字,返回布尔型数据
#语法  字符串序列.isalnum()
s='111aaa'
print(s.isalnum())    #ture
ss='111'
print(ss.isalnum())   #ture
sss='aaa'
print(sss.isalnum())   #ture
ssss='123...'
print(ssss.isalnum())   #False
#isspace(),判断字符串是否只含空白,返回布尔型数据
s1='1 1 1 '
print(s1.isspace())   #False
s2='   '
print(s2.isspace())    #ture