我用strip()分割后得到多个str,我怎么能把这多个str拼接成一个str?
2条回答 默认 最新
threenewbee 2023-04-04 13:17关注用join
text = " hello world " words = text.strip().split() result = " ".join(words) print(result)本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 1无用
用join
text = " hello world "
words = text.strip().split()
result = " ".join(words)
print(result)