Home >Backend Development >Python Tutorial >python function - cmp(x,y)
Today I will share a very useful and very simple function cmp in Python. You may have guessed it from the spelling. This is a comparison function. Well, yes, it has only three return values, positive number, 0, and negative number. Let’s take a look:
cmp(x, y)
Chinese description: Compare two objects x and y, if x y, return a positive number.
Version: This function is only available in python2 and is available in all versions of python2. However, this function has been deleted in python3, so special attention should be paid to this.
English description: Compare the two objects x and y and return an integer according to the outcome.