python remove consecutive spaces in a string leaving only one

The goal is to remove extra space characters, in adjacent strings, keep only one space

Purple Indus - Eggshell Apartment Chaoyang Branch Zheng Tianli

 

You can use the following methods:

If you don't distinguish between tabs, this will do: ' '.join(s.split())

 

Purple Indus - Eggshell Apartment Chaoyangmen Zheng Tianli

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324725005&siteId=291194637