如何在Python中为列表分配25个内存空间?

时间:2015-07-12 19:39:34

标签: python list loops

在java中它将是:                int Bit_list [] = new int Bit_list [25];

我可以通过循环完成它并像这样追加:

Bit_list = ['x']

"""
        loop to make space in memory for Bit_list
"""

a = 0
while  (a != 21):

    appd = 'x'
    Bit_list.append(appd)

    a  += 1

有更好的方法吗?

1 个答案:

答案 0 :(得分:1)

这是一种方法:

lst = 25 * [None]
print(lst)