On Sun, Jun 13, 2010 at 10:35 PM, madhuri vio <madhuri....@gmail.com> wrote: > i have a doubt about ...this..can u look into this.. > > a = open("human.odt","r") > b = a.readlines() > print b > > and i get d output something else... > > python monday.py > ["PK\x03\x04\x14\x00\x00\x00\x00\x00\xd6+\xce<^\xc62\x0c'\x00\x00\x00'\x00\x00\x00\x08\x00\x00\x00mimetypeapplication/vnd.oasis.opendocument.textPK\x03\x04\x14\x00\x00\x00\x00\x00\xd6+\xce<\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00Configurations2/statusbar/PK\x03\x04\x14\x00\x08\x00\x08\x00\xd6+\xce<\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'\x00\x00\x00Configurations2/accelerator/current.xml\x03\x00PK\x07\x08\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00PK\x03\x04\x14\x00\x00\x00\x00\x00\xd6+\xce<\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00Configurations2/floater/PK\x03\x04\x14\x00\x00\x00\x00\x00\xd6+\xce<\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00Configurations2/popupmenu/PK\x03\x04\x14\x00\x00\x00\x00\x00\xd6+\xce<\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00Configurations2/progressbar/PK\x03\x04\x14\x00\x00\x00\x00\ > > something of this sort...i have asked this doubt earlier..noe i am unable to > proceed... > can u help me in this > > -- > madhuri :) >
Well yes, this is exactly what you should get. Do you understand how files work? They are all just 1s and 0s. Different programs have different ways of interpreting those 1s and 0s. Python's open statement works like a basic text editor- it reads a byte and matches it to a character. There is no formatting, there is no color, there are no fonts. It just reads the bytes, and prints out the character or the hex code if it doesn't know how to print that byte. The three letters at the end of the file mean nothing- they're just part of the file name. In reality, all they do is tell your Operating System which program to use when you try to open the file. Now other programs will do something else to it. 7-zip will see this as a zip-compressed folder and uncompress it. OpenOffice for instance will look at this file as a document. It will call a routine that looks at this file as a zip-compressed folder and will uncompress it. Then, another routine will see it as a directory containing XML files, images, and whatever else is in there. It will parse those XML files and create the image of the document which then gets displayed on the screen. If you want to read an odt file in a coherent way, you need a library that understands the odt format. The open function isn't magic- it just reads files. -- http://mail.python.org/mailman/listinfo/python-list