目录
拆分 spilt
"""
拆分 spilt string > list
def split(self,
sep: Optional[str] = ...,
maxsplit: int = ...) -> List[str]
"""
language = "Python,Java,Go,C#,C++,Scala,JavaScript,PHP,Vue"
spilt_result = language.split(",")
print("spilt_result : ", spilt_result)
连接 join
"""
连接 join list > string
def join(self, __iterable: Iterable[str]) -> str
"""
list02 = " - ".join(spilt_result)
print("list02 : ", list02)
去空 strip
"""
去空 strip
def strip(self, __chars: Optional[str] = ...) -> str
"""
sick = " work, study"
print(sick.strip())
判断首尾 startwith,endwith
"""
判断首尾
startswith(self, prefix, start=None, end=None) :
区分大小写
范围 0 <= x < 6
"""
print(list02.startswith("Python"))
print(list02.endswith("Vue"))
print(list02.startswith("Python", 0, 6))
运行结果
spilt_result : ['Python', 'Java', 'Go', 'C#', 'C++', 'Scala', 'JavaScript', 'PHP', 'Vue']
list02 : Python - Java - Go - C# - C++ - Scala - JavaScript - PHP - Vue
work, study
True
True
True