字符串
1:字符串的定义:双引号或者单引号中的数据,就是字符串吧

2:转义字符
在需要在字符中使用特殊字符时,python用反斜杠(\)转义字符
3:运算符:

4:常见操作1-查找:
4.1:string.find(str, beg=0, end=len(string))
检测 str 是否包含在 string 中,如果 beg 和 end 指定范围,则检查是否包含在指定范围内,如果是返回开始的索引值,否则返回-1
4.2:string.rfind(str, beg=0, end=len(string))
类似于 find()函数,不过是从右边开始查找.
4.3:string.index(str, beg=0, end=len(string))
类似于 find()函数,但是找不到报异常.
4.4:string.rindex(str, beg=0, end=len(string))
类似于 rfind()函数,但是找不到报异常.


5:常见操作2-统计,3-分割
5.1:string.count(str, beg=0, end=len(string))
检测 str 是否包含在 string 中出现的次数,如果 beg 和 end 指定范围,则检查是否包含在指定范围内:
5.2:string.split(str="", num=string.count(str))
以str为分隔符切片string,如果num有指定值,则仅分隔num个子字符串:
5.3:string.splitlines([keepends])
按照行('\r', '\r\n', \n')分隔,返回一个包含各行作为元素的列表,如果参数keepends为False,不包含换行符,如果为True,则保留换行符。
5.4:string.partition(str)
有点像find()和split()的结合体,从str出现的第一个位置起,把 字 符 串string分 成 一 个3元 素 的 元 组(string_pre_str,str,string_post_str),如果string中不包含str则string_pre_str == string.
5.5:string.rpartition(str)
类似于partition()函数,不过是从右边开始.

6:常见操作3-判断
6.1:string.startswith(obj, beg=0,end=len(string))
检查字符串是否是以 obj 开头,是则返回 True,否则返回 False。如果beg 和 end 指定值,则在指定范围内检查.:
6.2:string.endswith(obj, beg=0,end=len(string))
检查字符串是否是以 obj 结尾,是则返回 True,否则返回 False。如果beg 和 end 指定值,则在指定范围内检查.
6.3:string.isalnum() 所有字符都是字母或数字则返回 True,否则返回 False:
6.4:string.isalpha() 所有字符都是字母则返回 True,否则返回 False:
6.5:string.isdigit() 所有字符都是数字则返回 True,否则返回 False:
6.6:string.isupper() 所有字符都是大写则返回 True,否则返回 False
6.7:string.islower() 所有字符都是小写则返回 True,否则返回 False
6.8:string.isspace() 只包含空格则返回 True,否则返回 False

7:常见操作4-大小写


8:常见操作5-对齐


9:常见操作6-裁剪


10:列表生成式

11:ipython3的保存方法

12:字符串的遍历方法

13:使用help(str.(方法))

14:常见操作-8合并
string.join(seq)
以 string 作为分隔符,将 seq 中所有的元素(的字符串表示)合并为一个新的字符串

15:常见操作9解码编码
1.1:string.encode(encoding='UTF-8', errors='strict')
以 encoding 指定的编码格式编码 string,如果出错默认报一个ValueError 的异常,除非 errors 指定的是'ignore'或者'replace':
1.2:bytes.decode(encoding='UTF-8', errors='strict')
以 encoding 指定的编码格式解码 string,如果出错默认报一个 ValueError 的 异 常 , 除 非 errors 指 定 的 是 'ignore' 或 者'replace'
