Python基础----字符串基本操作
1.find与index

find(查找数据第一次出现时对应的索引
没有这个数据时不报错返回一个 -1)
index(查找数据第一次出现时对应的索引
没有这个数据时会报一个错误) 如上图
2.count

count(查找一个字符串中某个字符出现的次数)
3.replace替换

replace(替换字符串中指定的字符,如果指定次数就替换这个字符出现了几次的字符)
4.split

splic("一个空格")把字符串排列成一个列表
split("一个空格",指定split值)分隔split个子字符串
5.capitalize与title

capitalize(把字符串的首字母大写)
title(把字符串的每个单词首字母大写)
6.startswith与endswith

startswith(判断字符串首字母是不是大写,是返回True,不是则返回False)
endswith(判断字符串末尾第一个字母是不是大写,是就返回True,不是则返回False)
7.lower与upper

lower(把字符串中的大写字母替换为小写)
upper(把字符串中的小写字母替换为大写)
8.ljust | rjust | center

ljust(使字符串左对齐并添加比原来字符串长度多出来的字符串(如图)不添加字符的话自动用空格补齐)
rjust(使字符串右对齐并添加比原来字符串长度多出来的字符串,不添加字符系统自动使用空格补齐)
center(把字符串剧中对齐,多出来的系统自动用空格补齐)以上三种情况均可以在多出来的部分添加子字符串
9.rstrip | lstrip | strip

rstrip(删除字符串左边的空白字符)
lstrip(删除字符串右边的空白字符)
strip(删除字符串左右两边的空白字符)
10.partition与rpatition

partition(是把字符串分为三部分,从你输入的字符串开始分割前面是一部分,后面是一部分,中间就是你要从某个字符串分割。)
rpartition(和上面的一样,只不过是从右边开始。)
11.splitlines

splitlines(把字符串变成一个列表)
12.isalpha

isalpha(字符串的子字符串都是字母的话返回True,不是的话返回False。)
13.isdigit

isdigit(字符串中只有数字返回True,则返回False。)
14.isalnum

isalnum(字符串中包含数字和字母返回True,只包含数字或者字母也返回True,如果不是以上情况都返回False)
15.isspace

isspace(如果一个字符串里面只有空格返回True,则返回False。)
16.join

join(在字符串中每个子字符串后面加上另一个字符串,组合成为一个新的字符串。如图)