其他分享
首页 > 其他分享> > 按要求数目分行

按要求数目分行

作者:互联网

from math import ceil


def split_word(lst, size):
word_list = list(
map(lambda x: lst[x * size:x * size + size],
list(range(0, ceil(len(lst) / size)))))
words = ''
if size == 1:
for word in word_list:
words += word
else:
for word in word_list:
words += word + '\n'
return words

标签:map,要求,word,分行,list,lst,words,数目,size
来源: https://www.cnblogs.com/wolvies/p/16529293.html