/ Published in: Python
                    
                                        
Tres formas de comprobar la existencia de un archivo:
Three ways to test the existence of a file:
                Three ways to test the existence of a file:
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
file = "/usr/bin/firefox"
def CheckFile(file):
import os.path
if os.path.exists(file):
print "The file exists"
else:
print "The file does not exist"
def CheckFile2(file):
import os.path
if os.path.isfile(file):
print "The file exists"
else:
print "The file does not exist"
def CheckFile3(file):
try:
archive = open(file)
print "The file exists"
except IOError:
print "The file does not exist"
URL: http://www.codigopython.com.ar/miniguias/tres-formas-de-comprobar-la-existencia-de-un-archivo
Comments
 Subscribe to comments
                    Subscribe to comments
                
                