情境:我有一大块文本,我想分解成更小的字符串。每n个字之后。在
text = This is a small example Text, showcasing my desired output.
应按n=4分为:
textList = ['This is a small', 'example Text, showcasing my', 'desired output.']
我的想法是把它分成一个只有单字的列表:
n = len(text)
textList = text.split(' ', n)
然后使用join()将其组合在一起,但我被卡住了,因为:
for x in range(0, 3):
' '.join(textList)
没有把我想要的输出列表放在一起
试试这个:
相关问题 更多 >
编程相关推荐