Check if file exists

/ Published in: Python
Save to your folder(s)

Copy this code and paste it in your HTML
  1. try:
  2. file = open("testfile", 'r')
  3. print "File exists."
  4. file.close()
  5. except IOError:
  6. print "File does not exist."

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.