Difference between os.path.exists and os.path.isfile?

os.path.isfile will return false if the argument is not a file: that is, it is a directory, or it does not exist.

os.path.exists returns if it is a valid path(check for directory or file, both) and os.path.isfile(checks for only file, not directory) returns if it is a file. so when os.path.isfile is True, os.path.exists also True and when os.path.exists is False, os.path.isfile is also False

reference:
https://stackoverflow.com/questions/17752078/difference-between-os-path-exists-and-os-path-isfile

posted @ 2020-05-26 08:46  天冰老冰棍  阅读(334)  评论(0)    收藏  举报