Python file exist

Monday, October 31, 2011

Just provide a quick reference to myself. I forget the way of checking file exist from time to time.

>>> import os
>>> os.path.exists('c:\\abc\\file.txt')
True
>>>


>>> import os
>>> os.path.isfile('c:\\abc\\file.txt')
True
>>>