python怎么用正则表达式删除空行

如题所述

正则表达式替换所有空行(包括空格行)为空
import re
re.sub(r"\n[\s| ]*\n", '', open('d:/test.txt').read()())
温馨提示:答案为网友推荐,仅供参考
相似回答