当你需要需要一个序列的多份拷贝时,重复操作符非常有用,它的语法如下:
sequence * copies_int
In [1]: a = [1,2,3,4]
In [2]: a * 5
Out[2]: [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
当你需要需要一个序列的多份拷贝时,重复操作符非常有用,它的语法如下:
sequence * copies_int
In [1]: a = [1,2,3,4]
In [2]: a * 5
Out[2]: [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]