How to create a fix size list in python?

后端 未结 9 1786
不思量自难忘°
不思量自难忘° 2020-12-04 20:53

In C++, I can create a array like...

int* a = new int[10];

in python,I just know that I can declare a list,than append some items,or like..

9条回答
  •  伪装坚强ぢ
    2020-12-04 21:42

    fix_array = numpy.empty(n, dtype = object)
    

    where n is the size of your array

    though it works, it may not be the best idea as you have to import a library for this purpose. Hope this helps!

提交回复
热议问题