python - How to get numbers from filenames? -
i have many files in directory according key:
pic001.jpg pic002.jpg pic012.jpg [...] ico001.jpg ico002.jpg ico012.jpg [...]
and want list files , create structure this:
for r,d,f in os.walk(directory): file in f: if file.startswith("pic"): pic = file ico = ??? images_list.append({ 'big': directory + '/' + pic, 'thumb': directory + '/' + ico, })
how "pic" file , "ico" assigned him (only if ico exist)?
the simplest answer seems be:
ico = 'ico' + file[3:]
Comments
Post a Comment