矩阵中的Python矩阵

2024-04-25 23:40:27 发布

您现在位置:Python中文网/ 问答频道 /正文

在我的程序中,我使用以下变量:

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

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

^{pr2}$

结果是

  c=4
  d=4

我能像这样去吗

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

或者不知怎么的?在


Tags: 程序matrixpr2payoff
1条回答
网友
1楼 · 发布于 2024-04-25 23:40:27
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

相关问题 更多 >

    热门问题