python将字符串中多个空格换为一个空格

import re

str = 'abc def  gh ijk'
strAfter = re.sub(' +', '', str)
print(strAfter)
原文地址:https://www.cnblogs.com/WebLinuxStudy/p/14682134.html