1.字符串分割
str1 = "1234567580"
print(str1.split('5', 2))
# 以"5"为分隔符,分割两次
# 结果:['1234', '67', '80']
2.字符串切片
str1 = "0123456789"
# print(str1[::-1]) 倒序
print(str1[1:7:2])
# 结果:135
# [索引头索引尾,步长],结果包含索引头,不包含尾
3.字符串替换
str1 = "1534567580"
print(str1.replace('5', '2', 1))
# str.replace(old,new,count)
# 结果:1234567580
4.去除头尾指定字符
str1 = " 0012345 678900"
print(str1.strip('0'))
# 结果:12345 6789
# 不填字符,默认去除头尾空格;填字符,去除头尾指定字符