zoukankan      html  css  js  c++  java
  • python .tolist() 将数组或者矩阵转换成list

    python .tolist() 将数组或者矩阵转换成list

    from numpy import *
    a1 = [[1,2,3],[4,5,6]] #列表
    a2 = array(a1) #数组
    a2
    '''
    array([[1, 2, 3],
       [4, 5, 6]])
    '''
    a3 = mat(a1) #矩阵
    a3
    '''
    matrix([[1, 2, 3],
        [4, 5, 6]])
    '''
    a4 = a2.tolist()
    a4
    #[[1, 2, 3], [4, 5, 6]]
    a5 = a3.tolist()
    a5
    #[[1, 2, 3], [4, 5, 6]]
    a4 == a5
    #True
  • 相关阅读:
    C语言I博客作业09
    C语言I博客作业08
    14
    13
    12
    11
    10
    9
    8
    7
  • 原文地址:https://www.cnblogs.com/cgmcoding/p/13589317.html
Copyright © 2011-2022 走看看