Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
重複の可能性: Python での行列転置
私はマトリックスを持っています
A = [[0,0],[1,1]]
そして、そのコンポーネントをzipで圧縮したいと思います
(0,1),(0,1)
A に 2 つの行がある場合、これは次のようにして簡単に取得できます。
zip(A[0],A[1])
任意の次元の行列 A がある場合
A = [[0,0],[1,1],[2,2]]
一連の要素を圧縮する方法は?
アイデアをありがとう。
を使用しzip(*A)ます。
zip(*A)
>>> zip(*A) [(0, 1, 2), (0, 1, 2)]