How to use cmp() in Python 3?

后端 未结 5 1491
甜味超标
甜味超标 2020-12-01 09:18

I cannot get the command cmp() to work.

Here is the code:

a = [1,2,3]
b = [1,2,3]
c = cmp(a,b)
print (c)

I am getting

5条回答
  •  孤城傲影
    2020-12-01 09:35

    In Python 3.x you can import operator and use operator module's eq(), lt(), etc... instead of cmp()

提交回复
热议问题