python 字符串比較

cmp方法比較兩個對象,並根據結果返回一個整數。cmp(x,y)若是X< Y,返回值是負數 若是X>Y 返回的值爲正數。html

sStr1 = 'strch'
sStr2 = 'strchr'
print cmp( sStr1 , sStr2) ##-1
想要了解更多字符串相關的信息,能夠看下 python字符串
相關文章
相關標籤/搜索