python3.x中cmp函数会NameError: name 'cmp' is not defined【cmp函数在3.x开始就去掉了,若想实现比较功能可用operator】

**报错原因:**因为python3.x中cmp函数去掉了,如果需要实现比较功能,那么可引入operator 模块。 operator模块,适合任何对象,包含的方法有: operator实例 在python3.x中用cmp函数功能的实例 python3.x中运用cmp函数运行的结果
相关文章
相关标签/搜索