New function to replace CMP () function in Python2 (GT,GE,EQ,LE,LT) in Python3

Source: Internet
Author: User

Original source: http://blog.csdn.net/Artprog/article/details/52197779

The CMP () function is no longer available in Python3 and is replaced by the following five functions:

import operator       #首先要导入运算符模块operator.gt(1,2)      #意思是greater than(大于)operator.ge(1,2) #意思是greater and equal(大于等于)operator.eq(1,2) #意思是equal(等于)operator.le(1,2) #意思是less and equal(小于等于)operator.lt(1,2) #意思是less than(小于)


Even with the first five abbreviations as function names:

New function (GT,GE,EQ,LE,LT)

to replace the CMP () function in Python2 in Python3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.