cmp方法比較兩個對象,並根據結果返回一個整數。cmp(x,y)如果X< Y,返回值是負數 如果X>Y 返回的值為正數。
sStr1
=
'strch'
sStr2 = 'strchr'
print cmp( sStr1 , sStr2) ##-1
sStr2 = 'strchr'
print cmp( sStr1 , sStr2) ##-1
想要了解更多字符串相關的信息,可以看下
python字符串