function that tries to read a file and return its contents : Read : File PYTHON TUTORIALS


PYTHON TUTORIALS » File » Read »

 

function that tries to read a file and return its contents


def safe_read(filename):
    f = open(filename)
    try:
        data = f.read()
    except IOError:
        data = None
    finally:
        f.close()
    return data



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo File
» Read