正如你可以看到這是非常非常笨重。我將如何去自動檢測文件擴展名?自動檢測文件擴展名
txt_files = glob('*txt')
png_files = glob('*.png')
jpg_files = glob('*.jpg')
zip_files = glob('*.zip')
gif_files = glob('*.gif')
iso_files = glob('*iso')
epub_files = glob('*epub')
ico_files = glob('*.ico')
#Unimportant bit to question
for n in txt_files:
move_files(n, 'txt')
for n in png_files:
move_files(n, 'png')
for n in jpg_files:
move_files(n, 'jpg')
for n in zip_files:
move_files(n, 'zip')
for n in gif_files:
move_files(n, 'gif')
for n in iso_files:
move_files(n, 'iso')
for n in epub_files:
move_files(n, 'epub')
for n in ico_files:
move_files(n, 'ico')
是否有原因,你的一些擴展有'.',有些不? – abarnert 2014-11-03 20:20:32