1. 程式人生 > >python 判斷檔案還是資料夾

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)"