您的位置: 首页 > IT文章 > python将字符串中多个空格换为一个空格 python将字符串中多个空格换为一个空格 分类: IT文章 • 2025-02-02 13:28:43 import re str = 'abc def gh ijk' strAfter = re.sub(' +', '', str) print(strAfter)