strip()、rstrip()、lstrip()
点击查看代码
str1 = ' hello , welcome to the world '
# 去除字符串左右两边空白
str1.strip()
'hello , welcome to the world'
# 去除字符串右边空白
str1.rstrip()
' hello , welcome to the world'
# 去除字符串左边空白
str1.lstrip()
'hello , welcome to the world '