我有一个很长的字符串,我想把它分成几段,最多X个字符.但是,只有在一个空格处(如果字符串中的某个单词长于X个字符,只需将其放入自己的片段中).
我都不知道该怎么做...肾盂的
伪代码:
declare a list
while still some string left:
take the fist X chars of the string
find the last space in that
write everything before the space to a new list entry
delete everything to the left of the space
在我编写代码之前,是否有一些python模块可以帮助我(我不认为pprint可以)?