Created
April 7, 2016 19:10
-
-
Save FGFW/a632416cc5ac6162bdc27369c4984c68 to your computer and use it in GitHub Desktop.
python判断路径是目录还是文件.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| python判断路径是目录还是文件.py | |
| http://bbs.bathome.net/thread-39957-1-1.html | |
| 2016年4月8日 03:04:00 codegay | |
| """ | |
| 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment