字符串函数的总结
字符串拥有着许多的函数,能够实现拼接、拆分、大小写转换等功能;
- 大小写转换有关的函数:
capitalize()
、casefold()
、title()
、swapcase()
、upper()
、lower()
; - 字符串位置对齐:
center()
、ljust()
、rjust()
、zfill()
; - 字符串查找:
count()
、find()
、rfind()
、index()
、rindex()
; - 字符串替换:
expandtabs()
、replace()
、translate()
; - 字符串判断函数(其返回结果都为布偶类型):
startswith()
、endswith()
、isupper()
、islower()
、istitle()
、isalpha()
、isascii()
、isspace()
、isprintable()
、isdecimal()
、isdigit()
、isnumeric()
、isalnum()
、isidentifier()
; - 字符串的截取:
strip()
、lstrip()
、rstrip()
、removeprefix()
、removesuffix()
- 字符串的拆分&拼接:
partition()
、rpartition()
;