python中的字符串切片

版权声明: https://blog.csdn.net/miantian180/article/details/86474846

在日常的数据清洗中,我们经常运用替换,切片,或者是正则来堆数据进行处理,以达到我们想要的东西。

切片即[start:end:step]

[:] 提取从开头(默认位置0)到结尾(默认位置-1)的整个字符串
[start:] 从start 提取到结尾

[:end] 从开头提取到end - 1
[start:end] 从start 提取到end - 1
start:end:step] 从start 提取到end - 1,每step 个字符提取一个
左侧第一个字符的位置/偏移量为0,右侧最后一个字符的位置/偏移量为-1

猜你喜欢

转载自blog.csdn.net/miantian180/article/details/86474846