标签:dig str1 max 移除 常用 case swap iss index
常用操作与方法:
| 按索引取值 | str[index] |
| 切片 | ste[start:stop:step] |
| 长度 | len(str) |
| 成员运算in和not in | str1 in str2; str1 not in str2 |
| 移除空白 | str.strip() |
| 切分 | str.split() |
| 循环 | for i in str : |
需要掌握的:
| 左/右去除空白 | lstrip/rstrip | 截掉 string 左/右边的空格 |
| 大/小写 | upper/lower | 转换 string 中所有小写字符为大写/大写为小写 |
| 判定开始/结束字符 | startswith/endswith | |
| 右切分 | rsplit(sep=" ",maxsplit) | 以 sep为分隔符切片 string,如果 maxsplit 有指定值,则仅分隔 maxsplit个子字符串 |
| 联合 | str.join(seq) | 以 string 作为分隔符,将 seq 中所有的元素(的字符串表示)合并为一个新的字符串 |
| 替换 | str.replace(old,new) | |
| 是否为数字 | str.isdigit() |
其他操作:
| 查找 | find/rfind/index/rindex/count |
| 对其方式 | center/ljust/rjust/zfill |
| 扩张tab | expandtabs |
| 大小写 | capitalize/swapcase/title |
| is判断 | isalum/isalpha/islower/isspace/istitle |
标签:dig str1 max 移除 常用 case swap iss index
原文地址:https://www.cnblogs.com/Du704/p/11290755.html