On Thu, May 7, 2009 at 10:04 PM, Li Wang <li.wan...@gmail.com> wrote: > Hi all: > > I am trying to read a non-text file as a string by using Python > read(), however, it seems there is some thing wrong with it. I can use > read() on text file correctly, but unable to read .xls file correctly. > (The program can read any file correctly in Fedora 10) > > Any idea how to solve this problem?
You need to add a "b" to the `flags` argument to open() when you open the file, e.g. open("the_file.xls", "rb") Unlike *nix, Windows differentiates between binary and text files, hence the need for the "b" flag to specify which you're dealing with. Further info: http://docs.python.org/library/functions.html#open Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list