自学内容网 自学内容网

python清除空格函数

python清除空格函数

mystr = '    hello world and  itcast and itheima and Python    '
# lstrip() 删除字符串左侧空白字符
print(mystr.lstrip())  #  hello world and  itcast and itheima and Python  
# rstrip() 删除字符串右侧空白字符
print(mystr.rstrip())  #      hello world and  itcast and itheima and Python
# strip()  删除字符串两侧空白字符
print(mystr.strip())  #  hello world and  itcast and itheima and Python


原文地址:https://blog.csdn.net/m0_53073183/article/details/145269699

免责声明:本站文章内容转载自网络资源,如侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!