• <bdo id='dmw32'></bdo><ul id='dmw32'></ul>
  • <small id='dmw32'></small><noframes id='dmw32'>

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

    <tfoot id='dmw32'></tfoot>

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

        旧版本Python中字典中键的顺序

        Order of keys in dictionaries in old versions of Python(旧版本Python中字典中键的顺序)

          <tfoot id='qttbp'></tfoot>
            <bdo id='qttbp'></bdo><ul id='qttbp'></ul>
            <legend id='qttbp'><style id='qttbp'><dir id='qttbp'><q id='qttbp'></q></dir></style></legend>
            • <small id='qttbp'></small><noframes id='qttbp'>

                <tbody id='qttbp'></tbody>
                  <i id='qttbp'><tr id='qttbp'><dt id='qttbp'><q id='qttbp'><span id='qttbp'><b id='qttbp'><form id='qttbp'><ins id='qttbp'></ins><ul id='qttbp'></ul><sub id='qttbp'></sub></form><legend id='qttbp'></legend><bdo id='qttbp'><pre id='qttbp'><center id='qttbp'></center></pre></bdo></b><th id='qttbp'></th></span></q></dt></tr></i><div id='qttbp'><tfoot id='qttbp'></tfoot><dl id='qttbp'><fieldset id='qttbp'></fieldset></dl></div>
                  本文介绍了旧版本Python中字典中键的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  编码:

                  d = {'a': 0, 'b': 1, 'c': 2}
                  l = d.keys()
                  
                  print l
                  
                  这将打印['a', 'c', 'b']。我不确定方法keys()如何确定l中关键字的顺序。但是,我希望能够以"正确"的顺序检索关键字。当然,正确的顺序将创建列表['a', 'b', 'c']

                  推荐答案

                  您可以使用OrderedDict(需要Python2.7)或更高版本。

                  还要注意,OrderedDict({'a': 1, 'b':2, 'c':3})将不起作用,因为您使用{...}创建的dict已经忘记了元素的顺序。相反,您希望使用OrderedDict([('a', 1), ('b', 2), ('c', 3)])

                  文档中提到,Python2.7以下版本可以使用this配方

                  这篇关于旧版本Python中字典中键的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Is there a way of group by month in Pandas starting at specific day number?( pandas 有从特定日期开始的按月分组的方式吗?)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                    <legend id='eP1cu'><style id='eP1cu'><dir id='eP1cu'><q id='eP1cu'></q></dir></style></legend>

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

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

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