python 合并列表 从大到小排序

 

 

 

#!/usr/bin/env python
# -*- coding: utf-8 -*-

a = [1,2,3,4,5]
b = [6,7,8,9,10]

a.extend(b)
a.reverse()

 

>>> a = [1,2,3,4,5]
>>> b = [6,7,8,9,10]
>>>
>>> a.extend(b)
>>> a.reverse()
>>> print(a)
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
>>>

 

>>> a = [1,2,3,4,5]
>>> b = [6,7,8,9,10]
>>> a.extend(b)
>>> a
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> a.sort(reverse=True)
>>> a
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

 

posted @ 2019-04-10 14:17  minger_lcm  阅读(8254)  评论(0编辑  收藏  举报