1 2 3 4 5 6 7 8 9 10 11 12 13 |
<span class="cm-variable">arr</span> = <span class="cm-variable">np</span>.<span class="cm-property">array</span>([[<span class="cm-number">1</span>, <span class="cm-number">2</span>], [<span class="cm-number">3</span>, <span class="cm-number">4</span>], [<span class="cm-number">5</span>, <span class="cm-number">6</span>], [<span class="cm-number">7</span>, <span class="cm-number">8</span>]]) の二次元配列は以下のようになる [[<span class="cm-number">1</span> <span class="cm-number">2</span>] [<span class="cm-number">3</span> <span class="cm-number">4</span>] [<span class="cm-number">5</span> <span class="cm-number">6</span>] [<span class="cm-number">7</span> <span class="cm-number">8</span>]]</code><code class="cm-s-ipython language-python"> </code><code class="cm-s-ipython language-python"> 以下のように指定すると <span class="cm-builtin">print</span>(<span class="cm-variable">arr</span>[[<span class="cm-number">3</span>, <span class="cm-number">2</span>, <span class="cm-number">0</span>]]) このように出力 |
1 2 3 4 |
[[<span class="cm-number">7</span> <span class="cm-number">8</span>] [<span class="cm-number">5</span> <span class="cm-number">6</span>] [<span class="cm-number">1</span> <span class="cm-number">2</span>]] |
コメントを残す