0

在我的程序中,我使用这个 var:

payoff_matrix = [ [(4,4),(1,6)] , [(6,1),(2,2)] ]

我需要检查(4,4)和(2,2),(可以是任何东西)我使用

  a=payoff_matrix[0]
  b=a[0]
  c=b[0]
  d=b[1]

结果是

  c=4
  d=4

我可以去那种地方吗

c=payoff_matrix[0].[0].[0]

或以某种方式?

4

1 回答 1

1
In [4]: mat = [ [(4,4),(1,6)] , [(6,1),(2,2)] ]

In [6]: c,d=mat[0][0]    #here mat[0] is [(4,4),(1,6)], invoking [0] on this yields [4,4]

In [7]: c
Out[7]: 4

In [8]: d
Out[8]: 4


In [9]: a,b=mat[1][1]  #here mat[1] is [(6,1),(2,2)], invoking [1] on this yields [2,2]

In [10]: a
Out[10]: 2

In [11]: b
Out[11]: 2
于 2012-10-09T10:15:00.773 回答