How to declare and add items to an array in Python?

前端 未结 7 602
轮回少年
轮回少年 2020-11-28 01:46

I\'m trying to add items to an array in python.

I run

array = {}

Then, I try to add something to this array by doing:



        
7条回答
  •  悲哀的现实
    2020-11-28 02:10

    You can also do:

    array = numpy.append(array, value)
    

    Note that the numpy.append() method returns a new object, so if you want to modify your initial array, you have to write: array = ...

提交回复
热议问题