python初始化定长列表



>>> lst = ['x' for n in range(5)]
>>> print(lst)
['x', 'x', 'x', 'x', 'x']
>>> lst = ['z']*5
>>> print(lst)
['z', 'z', 'z', 'z', 'z']
>>> lst = [0]*3
>>> print(lst)
[0, 0, 0]

 

posted @ 2019-09-09 00:57  -零  阅读(2577)  评论(0编辑  收藏  举报