1.lstrip:去掉左边空格
2.rstrip:去掉右边空格
3.strip:去掉左、右两边空格
案例:
name=" 东 宫 "
#输入原字符串来与新字符串做对比
print(name)
print(name.lstrip())
print(name.rstrip())
print(name.strip())
运行结果:
1.lstrip:去掉左边空格
2.rstrip:去掉右边空格
3.strip:去掉左、右两边空格
案例:
name=" 东 宫 "
#输入原字符串来与新字符串做对比
print(name)
print(name.lstrip())
print(name.rstrip())
print(name.strip())
运行结果: