There are the following files:
/images/1.png
/images/2.png
/images/10.png
/images/100.png
/images/a .png
How to find and traverse all files named with numbers?
for i in glob.glob(r'/images/[0-9].png'):
This can only match 1.png and 2.png.
PHP中文网2017-06-28 09:25:17
result = [i for i in glob.glob('/images/[0-9]*.png') if i.split('.')[0].isdigit()]
for i in result:
print(i)