goovy string 字符串 去除空行
以下是Python代码示例,可用于去除Groovy字符串中的空行:
groovy_str = "some text\n\nmore text\n\n\nfinal text\n"
# 原始Groovy字符串
cleaned_str = "\n".join([line for line in groovy_str.splitlines() if line.strip()])
# 去除空行后的Groovy字符串
print(cleaned_str)
输出:
some text
more text
final text
原文地址: http://www.cveoy.top/t/topic/dfpW 著作权归作者所有。请勿转载和采集!