📅  最后修改于: 2022-03-11 14:47:19.558000             🧑  作者: Mango
text = "hello, this is some text to break up, with some reeeeeeeeeaaaaaaally long words."
n = 16
words = iter(text.split())
lines, current = [], next(words)
for word in words:
if len(current) + 1 + len(word) > n:
lines.append(current)
current = word
else:
current += " " + word
lines.append(current)