python有哪些方法可让list中的元素重复N次
2个回答
展开全部
试试这个方法:
from itertools import chain, repeat
from functools import partial, reduce
this_is_a_list = [1, 2, 3, 4, 5]
what_you_want = reduce(
chain, map(list, map(partial(reduce, times=2), this_is_a_list)))
from itertools import chain, repeat
from functools import partial, reduce
this_is_a_list = [1, 2, 3, 4, 5]
what_you_want = reduce(
chain, map(list, map(partial(reduce, times=2), this_is_a_list)))
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询