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

猜你喜欢

转载自www.cnblogs.com/3nohtyp/p/12963298.html