python 判断文件还是文件夹的简单实例

如下所示:

import os
if os.path.isdir(path):
  print "it's a directory"
elif os.path.isfile(path):
  print "it's a normal file"
else:
  print "it's a special file(socket,FIFO,device file)"

相关推荐