str = ' 123 456 '
print(str.strip())
#去除左右两边的空格
print(str.lstrip())
#去除左边的空格
print(
python怎么去除字符串的空格、回车
最新推荐文章于 2023-04-23 10:55:04 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)
str = ' 123 456 '
print(str.strip())
#去除左右两边的空格
print(str.lstrip())
#去除左边的空格
print(