Multidimensional array in Python

前端 未结 12 1731
独厮守ぢ
独厮守ぢ 2021-02-04 15:49

I have a little Java problem I want to translate to Python. Therefor I need a multidimensional array. In Java it looks like:

double dArray[][][] = new double[x.l         


        
12条回答
  •  轮回少年
    2021-02-04 16:32

    For numeric data, Numpy Arrays:

    >>> matrix1 = array(([0,1],[1,3]))
    >>> print matrix1
    [[0 1]
    [1 3]]
    

    For general data (e.g. strings), you can use a list of lists, list of tuples, ...

    matrix2 = [['a','b'], ['x','y']]
    

提交回复
热议问题