1、lstrip():删除字符串左侧空⽩字符。
学习代码如下:
mystr = " hello world and itcast and itheima and Python "
# lstrip() 删除字符串左侧空⽩字符
new_str = mystr.lstrip()
print(new_str)
运行结果如下:
2、rstrip():删除字符串右侧空⽩字符。
学习代码如下:
# rstip() 删除字符串右侧空白字符
new_str = mystr.rstrip()
print(new_str)
运行结果如下:
3、strip():删除字符串两侧空⽩字符。
学习代码如下:
# strip() 删除字符串两侧空白字符
new_str = mystr.strip()
print(new_str)
运行结果如下: