Python 去除字符串中的空行时间:2025-03-14 22:07:25Python 去除字符串中的空行 mystr = 'adfa\n\n\ndsfsf' print("".join([s for s in mystr.splitlines(True) if s.strip()]))