56游戏网 - 努力做内容最丰富最安全的下载站!

56游戏网

当前位置:56游戏 > 源码技巧 > 父类数据 > python检测是文件还是目录的方法

python检测是文件还是目录的方法

发表时间:2015-07-04 10:23:13作者:zhao人气:更新时间:2026-02-18 20:07:53

本文实例讲述了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)"

希望本文所述对大家的Python程序设计有所帮助。

标签python,检测,文件,还是,目录,方法,本文,实例,讲述

相关下载

查看所有评论+

网友评论

网友
您的评论需要经过审核才能显示

公众号