python中的lstrip、rstrip、strip

it2026-05-12  4

python中的lstrip、rstrip、strip

lstrip()移除左侧空白符

rstrip()移除右侧空白符

strip()移除两边的空白符

1 a = " hello world" 2 a1 = a.lstrip()3 print(a1)

输出结果:

hello world

 

1 b = "hello world " 2 b1 = b.rstrip() 3 print(b1)

输出结果:

hello world

 

1 c = " hello world " 2 c1 = c.strip() 3 print(c1)

输出结果:

hello world

使用方法如代码书写

posted on 2019-04-09 10:11 恒笛 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/xwqhl/p/10675205.html

最新回复(0)