我用strip()分割后得到多个str,我怎么能把这多个str拼接成一个str?
用join
text = " hello world "
words = text.strip().split()
result = " ".join(words)
print(result)
strip()是去除字符串两边的空格和换行的,split()是分割字符串的
如果你想把多个字符串拼接成一个,可以使用for遍历列表使用+=的操作进行,也可以使用"".join(list)的方式进行拼接
帮到点采纳