<bdo id='5G2Pk'></bdo><ul id='5G2Pk'></ul>

    <small id='5G2Pk'></small><noframes id='5G2Pk'>

    1. <i id='5G2Pk'><tr id='5G2Pk'><dt id='5G2Pk'><q id='5G2Pk'><span id='5G2Pk'><b id='5G2Pk'><form id='5G2Pk'><ins id='5G2Pk'></ins><ul id='5G2Pk'></ul><sub id='5G2Pk'></sub></form><legend id='5G2Pk'></legend><bdo id='5G2Pk'><pre id='5G2Pk'><center id='5G2Pk'></center></pre></bdo></b><th id='5G2Pk'></th></span></q></dt></tr></i><div id='5G2Pk'><tfoot id='5G2Pk'></tfoot><dl id='5G2Pk'><fieldset id='5G2Pk'></fieldset></dl></div>
      <legend id='5G2Pk'><style id='5G2Pk'><dir id='5G2Pk'><q id='5G2Pk'></q></dir></style></legend>

      1. <tfoot id='5G2Pk'></tfoot>

        如何从元组列表中提取第 n 个元素

        时间:2023-09-01

            <tbody id='UwSj2'></tbody>

            <small id='UwSj2'></small><noframes id='UwSj2'>

              <bdo id='UwSj2'></bdo><ul id='UwSj2'></ul>
              1. <legend id='UwSj2'><style id='UwSj2'><dir id='UwSj2'><q id='UwSj2'></q></dir></style></legend>

              2. <i id='UwSj2'><tr id='UwSj2'><dt id='UwSj2'><q id='UwSj2'><span id='UwSj2'><b id='UwSj2'><form id='UwSj2'><ins id='UwSj2'></ins><ul id='UwSj2'></ul><sub id='UwSj2'></sub></form><legend id='UwSj2'></legend><bdo id='UwSj2'><pre id='UwSj2'><center id='UwSj2'></center></pre></bdo></b><th id='UwSj2'></th></span></q></dt></tr></i><div id='UwSj2'><tfoot id='UwSj2'></tfoot><dl id='UwSj2'><fieldset id='UwSj2'></fieldset></dl></div>

                <tfoot id='UwSj2'></tfoot>
                  本文介绍了如何从元组列表中提取第 n 个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试从元组列表中获取第 n 个元素.

                  I'm trying to obtain the n-th elements from a list of tuples.

                  我有类似的东西:

                  elements = [(1,1,1),(2,3,7),(3,5,10)]
                  

                  我希望只将每个元组的第二个元素提取到一个列表中:

                  I wish to extract only the second elements of each tuple into a list:

                  seconds = [1, 3, 5]
                  

                  我知道这可以通过 for 循环来完成,但我想知道是否还有其他方法,因为我有数千个元组.

                  I know that it could be done with a for loop but I wanted to know if there's another way since I have thousands of tuples.

                  推荐答案

                  n = 1 # N. . .
                  [x[n] for x in elements]
                  

                  这篇关于如何从元组列表中提取第 n 个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为什么 Python 中没有元组理解? 下一篇:使用多个 __init__ 参数子类化元组

                  相关文章

                • <i id='0lxpf'><tr id='0lxpf'><dt id='0lxpf'><q id='0lxpf'><span id='0lxpf'><b id='0lxpf'><form id='0lxpf'><ins id='0lxpf'></ins><ul id='0lxpf'></ul><sub id='0lxpf'></sub></form><legend id='0lxpf'></legend><bdo id='0lxpf'><pre id='0lxpf'><center id='0lxpf'></center></pre></bdo></b><th id='0lxpf'></th></span></q></dt></tr></i><div id='0lxpf'><tfoot id='0lxpf'></tfoot><dl id='0lxpf'><fieldset id='0lxpf'></fieldset></dl></div>
                • <small id='0lxpf'></small><noframes id='0lxpf'>

                  1. <legend id='0lxpf'><style id='0lxpf'><dir id='0lxpf'><q id='0lxpf'></q></dir></style></legend>

                        <bdo id='0lxpf'></bdo><ul id='0lxpf'></ul>

                      <tfoot id='0lxpf'></tfoot>