a = " a b c "
a.strip()
print(a)
# 结果 'a b c'
a = " a b c "
a.lstrip()
print(a)
# 结果 'a b c '
a = " a b c "
a.rstrip()
print(a)
# 结果 ' a b c'
a = " a b c "
a.replace(" ", "")
print(a)
# 结果 'abc'
a = " a b c "
b = a.split() # 字符串按空格分割成列表
print(b)
# 结果 ['a', 'b', 'c']
c = "".join(b) # 使用一个空字符串合成列表内容生成新的字符串
print(c)
# 结果 'abc'
# 快捷用法
a = " a b c "
b = "".join(a.split())
# 结果 'abc'