纯真毛巾

文章
8
资源
0
加入时间
3年1月10天

Python2中的cmp()函数

1、概述比较两个数的大小,如果 x < y 返回 -1, 如果 x == y 返回 0, 如果 x > y 返回 1。注:cmp函数在python3中已经被去掉了。2、语法cmp( x, y )3、python3中实现比较的方法引入operator模块,适合任何对象。>>> import operator>>> operator.eq('hello', 'name');False&am