python 基础练习
(官方文档地址:https://docs.python.org)
1、列表排序
Python Console中自定义比较函数:
def com(x,y):
if x>y:
return 1
if x==y:
return 0
return -1
com(3,5)
-1
com(5,5)
0
com(6,1)
1
def com(x,y):
if x>y:
return 1
if x==y:
return 0
return -1
com(3,5)
-1
com(5,5)
0
com(6,1)
1