回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我有一个这样的命令:</p>
<pre><code>OrderedDict([
(1666, [
['2ZNV', 'EDO1', 14, '2FCN', 'CD', 119],
['2ZNV', 'EDO', 14, '2FCN', 'CD', 119]]),
(1056, [['2ZNV', 'EDO', 32, '2FCN','CD', 33]]),
(266, [['2ZNV', 'EDO', 14, '2FCN', 'CD', 19]]),
(171, [
['2ZNV', 'ZN', 9, '2FCN', 'DVA', 19],
['2ZNV', 'ZN', 9, '2FCN', 'CD', 19],
['2ZNV', 'ZN', 9, '2FCN', 'ACT', 19],
['2ZNV', 'EDO', 9, '2FCN', 'CD', 19],
['2ZNV', 'EDO', 9, '2FCN', 'DVA', 19]]),
(45, [
['2ZNV','EDO', 9, '2X8L', 'GOL', 5],
['2ZNV', 'ZN', 9, '2X8L', 'GOL', 5]]),
(6, [['2ZNV', 'EDO', 2, '2FCN', 'CD', 3]]),
(1, [['2ZNV', 'EDO', 1, '2FCN', 'CD', 1]])
])
</code></pre>
<p>是否可以添加<code>set</code>中的所有值,但保持顺序?在</p>
<p>我试图转换成list,然后从tuple转换成set,如下所示:</p>
^{pr2}$
<p>但这不是维持秩序。上述结果为:</p>
<pre><code>set([
('2ZNV', 'ZN', 9, '2FCN', 'DVA', 19),
('2ZNV', 'EDO', 14, '2FCN', 'CD', 119),
('2ZNV', 'EDO', 9, '2X8L', 'GOL', 5),
('2ZNV', 'EDO', 32, '2FCN', 'CD', 33),
('2ZNV', 'EDO', 9, '2FCN', 'DVA', 19),
('2ZNV', 'ZN', 9, '2FCN', 'ACT', 19),
('2ZNV', 'EDO', 9, '2FCN', 'CD', 19),
('2ZNV', 'EDO', 1, '2FCN', 'CD', 1),
('2ZNV', 'EDO', 14, '2FCN', 'CD', 19),
('2ZNV', 'ZN', 9, '2X8L', 'GOL', 5),
('2ZNV', 'EDO1', 14, '2FCN', 'CD', 119),
('2ZNV', 'EDO', 2, '2FCN', 'CD', 3),
('2ZNV', 'ZN', 9,'2FCN', 'CD', 19)
])
</code></pre>
<p>提前谢谢你。在</p>