python 2中,有cmp(a,b)函数,用于比较两个字符串的大小。
如
>>>a='abc'
>>>b='abd'
>>>print cmp(a,b)
-1
>>>b='abc'
0
>>>a='abz'
1
但是在 Python3 中,cmp() 函数被移除了,所以要避免少用这个函数。