相关疑难解决方法(0)

Python,按另一个列表对列表进行排序

我有一个清单a

a = ['c','d','b','a','e']
Run Code Online (Sandbox Code Playgroud)

和一个列表b

b = ['a001','b002','c003','d004','e005']
Run Code Online (Sandbox Code Playgroud)

我怎么能得到我的列表c如下:

c = ['c003','d004','b002','a001','e005']
Run Code Online (Sandbox Code Playgroud)

基本上b使用每个元素的一部分,按照 中定义的顺序进行排序a

非常感谢。

python python-2.7

7
推荐指数
3
解决办法
7003
查看次数

标签 统计

python ×1

python-2.7 ×1