1.字符串拆分split():

pandas 字符串操作

split经常和strip一起使用于修剪空白符

pandas 字符串操作

2.字符串拼接使用 ‘+’

pandas 字符串操作

有个更符合Python的字符串拼接方法是使用join()

pandas 字符串操作

3,判断是否是子字符串,可以使用in或find()或index(),find与index的区别是,find如果找不到字符串会返回-1,index则会抛出异常错误。

in

pandas 字符串操作

find()

pandas 字符串操作

index()

pandas 字符串操作

4.计算子字符串出现的次数count()

pandas 字符串操作

5.替换某个子字符串replace()

pandas 字符串操作

python内置字符串方法:

pandas 字符串操作

pandas 字符串操作

(图片来源:截图于 利用python进行数据分析 Wes McKinney 著)

相关文章: