[英]Python matrix in matrix in matrix
In my program I use this var: 在我的程序中,我使用以下变量:
payoff_matrix = [ [(4,4),(1,6)] , [(6,1),(2,2)] ]
And i need to check (4,4) and (2,2), (It can be anything) I use 我需要检查(4,4)和(2,2),(可以是任何东西)我使用
a=payoff_matrix[0]
b=a[0]
c=b[0]
d=b[1]
And result is 结果是
c=4
d=4
Can I go to that like 我可以这样去吗
c=payoff_matrix[0].[0].[0]
or somehow? 或以某种方式?
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.