首页 > 技术文章 > Python 去除字符串中的空行
ibingshan 2019-06-13 16:57 原文
mystr = 'adfa\n\n\ndsfsf' print("".join([s for s in mystr.splitlines(True) if s.strip()]))