• <small id='fAhoz'></small><noframes id='fAhoz'>

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

        • <bdo id='fAhoz'></bdo><ul id='fAhoz'></ul>
      1. 如何将嵌套列表列表转换为 python 3.3 中的元组列

        时间:2023-08-04
            <bdo id='N1C0k'></bdo><ul id='N1C0k'></ul>
            • <i id='N1C0k'><tr id='N1C0k'><dt id='N1C0k'><q id='N1C0k'><span id='N1C0k'><b id='N1C0k'><form id='N1C0k'><ins id='N1C0k'></ins><ul id='N1C0k'></ul><sub id='N1C0k'></sub></form><legend id='N1C0k'></legend><bdo id='N1C0k'><pre id='N1C0k'><center id='N1C0k'></center></pre></bdo></b><th id='N1C0k'></th></span></q></dt></tr></i><div id='N1C0k'><tfoot id='N1C0k'></tfoot><dl id='N1C0k'><fieldset id='N1C0k'></fieldset></dl></div>

              <tfoot id='N1C0k'></tfoot>
            • <small id='N1C0k'></small><noframes id='N1C0k'>

                    <tbody id='N1C0k'></tbody>
                  <legend id='N1C0k'><style id='N1C0k'><dir id='N1C0k'><q id='N1C0k'></q></dir></style></legend>
                  本文介绍了如何将嵌套列表列表转换为 python 3.3 中的元组列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试将嵌套的列表列表转换为 Python 3.3 中的元组列表.但是,似乎我没有这样做的逻辑.

                  I am trying to convert a nested list of lists into a list of tuples in Python 3.3. However, it seems that I don't have the logic to do that.

                  输入如下:

                  >>> nested_lst = [['tom', 'cat'], ['jerry', 'mouse'], ['spark', 'dog']]
                  

                  所需的输出应如下所示:

                  And the desired ouptput should look as exactly as follows:

                  nested_lst_of_tuples = [('tom', 'cat'), ('jerry', 'mouse'), ('spark', 'dog')]
                  

                  推荐答案

                  只需使用列表推导:

                  nested_lst_of_tuples = [tuple(l) for l in nested_lst]
                  

                  演示:

                  >>> nested_lst = [['tom', 'cat'], ['jerry', 'mouse'], ['spark', 'dog']]
                  >>> [tuple(l) for l in nested_lst]
                  [('tom', 'cat'), ('jerry', 'mouse'), ('spark', 'dog')]
                  

                  这篇关于如何将嵌套列表列表转换为 python 3.3 中的元组列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将字符串转换为 int 的简短方法 下一篇:Python3 错误:TypeError:无法将“字节"对象隐式转

                  相关文章

                  最新文章

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

                  1. <small id='8KCA5'></small><noframes id='8KCA5'>

                    <tfoot id='8KCA5'></tfoot>

                        <bdo id='8KCA5'></bdo><ul id='8KCA5'></ul>