• <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 - 将元组列表转换为字符串

        Python - convert list of tuples to string(Python - 将元组列表转换为字符串)

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

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Initialize Multiple Numpy Arrays (Multiple Assignment) - Like MATLAB deal()(初始化多个 Numpy 数组(多重赋值) - 像 MATLAB deal())
                  How to extend Python class init(如何扩展 Python 类初始化)
                  What#39;s the difference between dict() and {}?(dict() 和 {} 有什么区别?)
                  What is a wrapper_descriptor, and why is Foo.__init__() one in this case?(什么是 wrapper_descriptor,为什么 Foo.__init__() 在这种情况下是其中之一?)
                  Initialize list with same bool value(使用相同的布尔值初始化列表)
                  setattr with kwargs, pythonic or not?(setattr 与 kwargs,pythonic 与否?)
                  <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'>

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