Notes:
We use the
open(filename)
function to get a file handle, and then we use the read()
function of the file handle object to read the contents of the file as a string.I am sure there is a different way to read a binary file, and I am also sure there should be a way to buffer the input in case the file is very large, but
read
is the simplest way to get the job done. This is much better than Java where we have to jump through tons of hoops to read a file.
No comments:
Post a Comment