One - One Code All

Blog Content

python判断文件和文件夹是否存在isfile,isdir

Python   2008-02-17 19:22:04
>>> import os
>>> os.path.exists('d:/assist')
True
>>> os.path.exists('d:/assist/getTeacherList.py')
True
>>> os.path.isfile('d:/assist')
False
>>> os.path.isfile('d:/assist/getTeacherList.py')
True
>>> os.makedirs('d:/assist/set')
>>> os.path.exists('d:/assist/set')
True
>>> os.path.isdir(tobecheckdir)
True

os.path.isfile

os.path.isdir

os.path.exists


上一篇:python中float转为decimal
下一篇:Python中os.path.join方法 join方法

The minute you think of giving up, think of the reason why you held on so long.