擅长:python、mysql、java
<ol>
<li>您的代码对python无效。你知道吗</li>
<li>集合没有<a href="http://en.wikipedia.org/wiki/Set_%28mathematics%29" rel="nofollow">set</a>定义的顺序</li>
<li>可能需要使用<a href="http://docs.python.org/2/library/collections.html#collections.OrderedDict" rel="nofollow">^{<cd1>}</a>数据结构</li>
</ol>
<p>以下代码段显示了一个示例:</p>
<pre><code>>>> from collections import OrderedDict
>>> first_keys = OrderedDict.fromkeys('PEACH')
>>> first_keys.keys()
['P', 'E', 'A', 'C', 'H']
>>> second_keys = OrderedDict.fromkeys('DUE')
>>> second_keys.keys()
['D', 'U', 'E']
>>> first_keys.update(second_keys.items())
>>> first_keys.keys()
['P', 'E', 'A', 'C', 'H', 'D', 'U']
</code></pre>