My Tech Notes
Python: check if file or directory exists
os.path.exists
to check if file or directory exists.
import os
os.path.exists('/tmp/1.txt')
os.path.exists('/tmp')
os.path.isfile
to check if file exists.
import os
os.path.isfile('/tmp/1.txt')
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment