Is there a simple way to remove multiple spaces in a string?

后端 未结 29 1953
星月不相逢
星月不相逢 2020-11-22 08:17

Suppose this string:

The   fox jumped   over    the log.

Turning into:



        
29条回答
  •  深忆病人
    2020-11-22 09:03

    sentence = "The   fox jumped   over    the log."
    word = sentence.split()
    result = ""
    for string in word:
       result += string+" "
    print(result)
    

提交回复
热议问题