如何排序下面的python列表
nlist = [
"494=Deploy\00000001.inx",
"19=Deploy\0000000144.exe",
"2=Deploy\00000001_index.dat",
"9=Deploy\0000001b_index.bin",
"1=Deploy\00000001_index.bin",
"7=Deploy\00000019_index.bin",
"2=Deploy\00000001_Onedata.dat",
"19=Deploy\000000024444.exe"
]
至以下
sortedList = [
"1=Deploy\00000001_index.bin",
"2=Deploy\00000001_index.dat",
"2=Deploy\00000001_Onedata.dat",
"7=Deploy\00000019_index.bin",
"9=Deploy\0000001b_index.bin",
"19=Deploy\0000000144.exe",
"19=Deploy\000000024444.exe",
"494=Deploy\00000001.inx",
]
能不能做一个班轮
对列表排序并传递一个键,该键在
'='
上拆分列表中的字符串并选择数字部分,nlist.sort
修改原始列表,如果您想要一个新列表,最好使用sorted()
输出
相关问题 更多 >
编程相关推荐