import os
import string
os.chdir('C:\Python27')
x=os.listdir('C:\Python27')
y=[f for f in os.listdir(dirname)
if os.path.isfile(os.path.join(dirname, f))]
for k in y:
fileName, fileExtension = os.path.splitext(k)
print fileName,fileExtension
现在,我想按扩展名对文件进行排序。