对中文名称重排序
import functools
def cmp_str(s1, s2):
pos1 = s1.find('-')
pos2 = s2.find('-')
i1 = int(s1[:pos1])
i2 = int(s2[:pos2])
if i1 < i2:
return -1
if i1 > i2:
return 1
return 0
with open('E:\\vidlist.txt','r',encoding='UTF-8') as vislst:
vlst = vislst.readlines()
for v in vlst:
v=v.strip()
pos = v.find('-')
try:
i = int(v[:pos])
except:
print(v[:pos])
vlst = list(map(str.strip, vlst))
vlst.sort(key=functools.cmp_to_key(cmp_str))
for vid in vlst:
print(vid)