[Py023]List元素重复

【[Py023]List元素重复】list元素重复有两种情况,
1.按照顺序整体重复,直接*就可以

['a','b','c'] * 2 Out[22]: ['a', 'b', 'c', 'a', 'b', 'c']

2.每个元素一次重复
[i for i in ['a','b','c'] for j in range(2)] Out[23]: ['a', 'a', 'b', 'b', 'c', 'c']

    推荐阅读