Reorder the folders or files obtained by os.listdir


video_dirs = os.listdir (subject_root) # List 
video_dirs.sort (key = lambda x: int (x [5:])) # 5 indicates the starting position of sorting keywords, set by yourself

print:

['video1', 'video2', 'video3', 'video4', 'video5', 'video6', 'video7', 'video8', 'video9', 'video10', 'video11', 'video12']

Published 141 original articles · Like 54 · Visits 150,000+

Guess you like

Origin blog.csdn.net/iamjingong/article/details/101515290