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

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

    • <bdo id='G7M0d'></bdo><ul id='G7M0d'></ul>

      1. 元组键值

        时间:2023-08-31
            • <bdo id='vDSep'></bdo><ul id='vDSep'></ul>
              <tfoot id='vDSep'></tfoot>

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

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

                  <tbody id='vDSep'></tbody>

                  本文介绍了元组键值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  是否可以从元组中获取价值:

                  Is it possible to get Value out of tuple:

                  TUPLE = (
                      ('P', 'Shtg1'),
                      ('R', u'Shtg2'),
                      ('D', 'Shtg3'),
                  )
                  

                  通过调用像 P

                  Python 说只有 int 可以用于这种类型的查询"

                  Python says that only int can be used for this type of 'query'

                  我不能使用循环(开销太大...)

                  I can't use loop (too much overhead...)

                  谢谢!

                  推荐答案

                  此类查询的规范数据结构是字典:

                  The canonical data structure for this type of queries is a dictionary:

                  In [1]: t = (
                     ...:     ('P', 'Shtg1'),
                     ...:     ('R', u'Shtg2'),
                     ...:     ('D', 'Shtg3'),
                     ...: )
                  
                  In [2]: d = dict(t)
                  
                  In [3]: d['P']
                  Out[3]: 'Shtg1'
                  

                  如果使用元组,则无法避免循环(显式或隐式).

                  If you use a tuple, there is no way to avoid looping (either explicit or implicit).

                  这篇关于元组键值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何为元组增加价值? 下一篇:如何通过反向对元组进行排序,但打破非反向关系?(Python)

                  相关文章

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

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

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

                    1. <tfoot id='tYlSU'></tfoot>
                        <bdo id='tYlSU'></bdo><ul id='tYlSU'></ul>