擅长:python、mysql、java
<p>在每个<code>list</code>中逐项进行比较:</p>
<pre><code>>>> [1, 2] < [2, 1] # 1 < 2: because the first two items differ, comparison ends here
True
>>> [1, 2] == [1, 2] # 1 == 1 and 2 == 2
True
>>> [1, 2][0] < [2, 1][0] # 1 < 2
True
>>> [1, 2][1] > [2, 1][1] # 2 > 1
True
</code></pre>
<p>有关<a href="https://docs.python.org/3/tutorial/datastructures.html#comparing-sequences-and-other-types" rel="nofollow noreferrer">Comparing Sequences and Other Types</a>的详细信息:</p>
<blockquote>
<p>Sequence objects may be compared to other objects with the same sequence type. The comparison uses lexicographical ordering: first the first two items are compared, and if they differ this determines the outcome of the comparison; if they are equal, the next two items are compared, and so on, until either sequence is exhausted. If two items to be compared are themselves sequences of the same type, the lexicographical comparison is carried out recursively. If all items of two sequences compare equal, the sequences are considered equal.</p>
</blockquote>