Python matrix problems

后端 未结 3 896
情深已故
情深已故 2021-01-28 09:41

This is continued from this thread: Python matrix, any solution?


Input

from numpy import *
import numpy

x=[[\'1\',\'7\'],
 [\'1.5         


        
3条回答
  •  爱一瞬间的悲伤
    2021-01-28 10:22

    You are missing commas between the inner lists:

    x = [['1',   '7'],
         ['1.5', '8'],
         ['2',   '5.5'],
         ['2',   '9']]
    

    The error message stemmed from Python seeing ['1','7']['1.5','8'] and trying to use the tuple ('1.5','8') as an index into the list ['1','7'].

提交回复
热议问题