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

    <tfoot id='hyWBE'></tfoot>
    • <bdo id='hyWBE'></bdo><ul id='hyWBE'></ul>

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

        Python - 将元组列表转换为字符串

        时间:2023-08-31

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

              <tbody id='U6aH3'></tbody>
              <bdo id='U6aH3'></bdo><ul id='U6aH3'></ul>

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

                <legend id='U6aH3'><style id='U6aH3'><dir id='U6aH3'><q id='U6aH3'></q></dir></style></legend>
                • <tfoot id='U6aH3'></tfoot>
                  本文介绍了Python - 将元组列表转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  将元组列表转换为字符串的最 Pythonic 方式是什么?

                  Which is the most pythonic way to convert a list of tuples to string?

                  我有:

                  [(1,2), (3,4)]
                  

                  我想要:

                  "(1,2), (3,4)"
                  

                  我的解决方案是:

                  l=[(1,2),(3,4)]
                  s=""
                  for t in l:
                      s += "(%s,%s)," % t
                  s = s[:-1]
                  

                  有没有更 Pythonic 的方式来做到这一点?

                  Is there a more pythonic way to do this?

                  推荐答案

                  你可能想使用如下简单的东西:

                  you might want to use something such simple as:

                  >>> l = [(1,2), (3,4)]
                  >>> str(l).strip('[]')
                  '(1, 2), (3, 4)'
                  

                  .. 这很方便,但不能保证正常工作

                  .. which is handy, but not guaranteed to work correctly

                  这篇关于Python - 将元组列表转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 JSON 保存 Python 元组 下一篇:为什么当'[] is []'并且'{} is {}'返回False时'()是()

                  相关文章

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

                    <bdo id='Z3YVx'></bdo><ul id='Z3YVx'></ul>

                    <tfoot id='Z3YVx'></tfoot>

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

                    <legend id='Z3YVx'><style id='Z3YVx'><dir id='Z3YVx'><q id='Z3YVx'></q></dir></style></legend>