import res = '''挺进—撤退密集—稀疏倾斜—竖直暴躁—温和'''a= re.sub("\s+" , " ", s)print(a)b= re.sub("\n\n" , "\n", s)print(b)# 删除空行
删除字符串的空行,有多少种方法?-Python-CSDN问答