擅长:python、mysql、java
<p>字典不会按照您添加键/值对的顺序存储它们。。。除非使用<a href="http://docs.python.org/2/library/collections.html#collections.OrderedDict" rel="nofollow">^{<cd1>}</a>。方法如下:</p>
<pre><code>entries = [('Domain Source', 'Analyst'), ('Recommend Suppress', 'N'),
('Standard Error', '0.25'), ('Element ID', '1.A.1.d.1'),
('N', '8'), ('Scale ID', 'IM'), ('Not Relevant', 'n/a'),
('Element Name', 'Memorization'), ('Lower CI Bound', '2.26'),
('Date', '06/2006'), ('Data Value', '2.75'),
('Upper CI Bound', '3.24'), ('O*NET-SOC Code', '11-1011.00')]
from collections import OrderedDict
d = OrderedDict(entries)
d.keys()[2:]
=> ['Standard Error', 'Element ID', 'N', 'Scale ID', 'Not Relevant',
'Element Name', 'Lower CI Bound', 'Date', 'Data Value',
'Upper CI Bound', 'O*NET-SOC Code']
</code></pre>