- """
- python判断路径是目录还是文件.py
- """
- import os
- files=[r for r in open("test.txt") if os.path.isfile(r.strip())]
- dirs=[r for r in open("test.txt") if os.path.isdir(r.strip())]
- with open("11.txt","w+") as f:
- f.writelines(files)
- with open("22.txt","w+") as f:
- f.writelines(dirs)
- #该片段来自于http://www.codesnippet.cn/detail/0411201615120.html
来源: http://www.codesnippet.cn/detail/0411201615120.html