原博客链接本论坛禁止贴
>>> 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
遍历文件夹
参考
http://laocao.blog.51cto.com/480714/525140
>>> def Test2(rootDir):
... for lists in os.listdir(rootDir):
... path = os.path.join(rootDir, lists)
... print path
... if os.path.isdir(path):
... Test2(path)
...
>>> Test2("F:\zr")