1 字符串的变形
opper 将字符串中的所有的字母转化为大写
lower 将字符串当中的所有字母转化为小写
swapcase 将字符串当中的所有字母大写小写互换
title 将字符串当中的单词首字母大写,单词以非字母划分
capitalize 只有字符串的首字母大写
expandtabs 吧字符串中的tab符号('/t')转换为空格,tab 符号('/t')默认的空格数是8
s = 'hello Python'
print(s.upper())
print(s.lower())
print(s.swapcase())
print(s.title())
print(s.capitalize())
s1 ='hello \t python'
print(s1.expandtabs())
'''
HELLO PYTHON
hello python
HELLO pYTHON
Hello Python
Hello python
hello python
'''
2.字符串的判断
isalnum 判断字符串是否完全由字母或数字组成
isalpha 判断字符串是否完全由字母组成
isdigit 判断字符串是否完全由数字组成
isupper 判断字符串当中的字母是否完全是大写
islower 判断字符串当中的字母是否完全是小写
istitle 判断字符串是否满足title格式
isspace 判断字符串是否完全有空格组成
startswith 判断字符串的开头字符,也可以截取判断
endswith 判断字符串的结尾字符,也可以截取判断
split 判断字符串的分隔符切片
s1 = '10a-'
print(s1.isalnum())
s2 = 'hello'
print(s2.isalpha())
s3 = '234'
print(s3.isdigit())
s4 = 'HELLO'
print(s4.isupper())
s5 = 'hello'
print(s5.islower())
s6 = 'Hello Python'
print(s6.istitle())
s7 = ' '
print(s7.isspace())
s8 = 'hello python'
print(s8.startswith('he'))
print(s8.endswith('on'))
print(s8.endswith('io',0,5))
False
True
True
True
True
True
True
True
True
False