我需要打印出当前目录的 listdir,但按文件类型排序。像这样的东西:
ASCII text:
text
bzip2 compressed data, block size = 900k:
strace_4.5.20.orig.tar.bz2
gzip compressed data, extra field, from Unix:
openssh_5.8p1.orig.tar.gz
gzip compressed data, from Unix, last modified:
eglibc_2.11.2.orig.tar.gz
strace_4.5.20-2.debian.tar.gz
gzip compressed data, from Unix, max compression:
openssh_5.8p1-2.debian.tar.gz
PDF document, version 1.0:
attestazione.pdf
PDF document, version 1.2:
risPP.9dic03.pdf
risparz.7nov03.pdf
这一切都在 python 中。在linux上有file
命令。在python中怎么样?