python检测是文件还是目录的方法
时间:2021-12-14 10:43:52|栏目: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)"
希望本文所述对大家的Python程序设计有所帮助。
上一篇:Jupyter Notebook添加代码自动补全功能的实现
栏 目:Python代码
本文标题:python检测是文件还是目录的方法
本文地址:http://www.codeinn.net/misctech/186882.html






