```python
mystr='hello world and dgjfkhgj'#title():返回一个首字母大写的字符串print(mystr.title())#capitalize():返回第一个首字母大写的字符串print(mystr.capitalize())#upper()返回全部大写print(mystr.upper())#lower()返回全部小写print(mystr.lower())
mystr1='Hello World and dgjfkhgj'print(mystr1.lower())#swapcase()用于字符串的大小写进行转换print(mystr1.swapcase())
mystr2=' hello'#strip()去掉两边的空格print(mystr2.strip())#center(20)返回一个原字符串居中,并使用空格填充至长度,width的新字符串,默认填充字符为空格print(mystr2.center(20))
mystr3='hello word.\nThis is LiMing.\nHe is a student.'print(mystr3)
newstr3=mystr3.splitlines()print(newstr3)#isalpha:判断是否为字母,返回false或truestr='dgkfh'print(str.isalpha())#isdigit,isnumeric,isdecimal 判断是否为数字
str1='fdkgjfkb'print(str1.isdigit())
str2='2409605687'print(str2.isdecimal())#join:字符串的拼接
li=["My","name","is","lixiaohuan"]print(li)
sp=' '
new=sp.join(li)print(new)#isalnum()判断是否为字母或数字组成,只要有字母,就返回true,不能有标点符号或者空格(特殊符号)
str3='石家 庄'print(str3.isalnum())
str4='石家庄'print(str4.isalnum())
str5='vcjdlf'#isspace()确认是否有空格print(str5.isspace())
字符串的练习```pythonmystr='hello world and dgjfkhgj'#title():返回一个首字母大写的字符串print(mystr.title())#capitalize():返回第一个首字母大写的字符串print(mystr.capitalize())#upper()返回全部大写print(mystr.upper())#lower()返回全部小写...