Skip to content

Commit df8403c

Browse files
committed
Update 111.md
新增cmp()函数的解释和官方文档描述。标注出cmp()函数只在Python2中出现,Python3中已经删除。
1 parent 87728b3 commit df8403c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎111.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,13 @@ list和str两种类型的数据,有共同的地方,它们都属于序列(
214214
>>> min(lst)
215215
'c++'
216216

217-
- cmp()
218-
217+
- cmp():
219218
采用上面的方法,进行比较
219+
[官方文档] https://docs.python.org/2.7/library/functions.html#cmp
220+
Compare the two objects x and y and return an integer according to the outcome. The return value is negative if x < y, zero if x == y and strictly positive if x > y.
221+
cmp是英文单词compare的缩写,即该函数是比较两个对象x和y大小的。如果x < y ,返回负数;x == y, 返回0;x > y,返回正数。
222+
#注意:这个内置函数只在Python2版本中有,Python3版本中没有。
223+
220224

221225
>>> lsta = [2,3]
222226
>>> lstb = [2,4]

0 commit comments

Comments
 (0)