1.字符串查找常用方法
a = "asdfghjklk"
print(a.find("v"))
print(a.rindex("k"))
2.字符串判断常用方法
print('hello'.startswith("h"))
print('hello'.endswith("o"))
print('hello123'.isalpha())
print('123'.isdigit())
print("12yy".isalnum())
print(' '.isspace())
3.替换字符串
hello = "hello"
print(hello.replace("h", "kkkk"))
4.字符串内容分割常用方法
he = 'a-b-c-d-e-f-g'
print(he.split("-"))
print(he.rsplit("-", 3))
ass = "asdFggFh"
print(ass.partition("F"))
print(ass.rpartition("F"))
5.其它常用方法
print(ass.capitalize())
print(ass.upper())
print(ass.lower())
print(ass.title())
print(ass.ljust(15))
print(ass.ljust(15, "+"))
print(ass.rjust(15, '+'))
print(ass.center(20, "+"))
sd = " app "
print(sd.lstrip())
print(sd.rstrip())
print(sd.strip())
res = ['a', 'b', 'c', 'd', 'e', 'f']
print('-'.join(res))