[Tutor] a quick Q: how to use for loop to read a series of files with .doc end
wprins at gmail.com
Thu Sep 29 17:18:49 CEST 2011
On 29 September 2011 16:13, lina <lina.lastname at gmail.com> wrote:
> mport os.path
> for fileName in os.listdir("."):
> if os.path.isfile(fileName) and os.path.splitext(fileName)=="xpm":
> filedata = open(fileName,'r')
> for line in text:
> print line
> why here I print nothing out?
> There is .xpm file there with content.
Is your .xpm files actually text files? Or are they binary (e.g. maybe
graphics) files? (XPM is normally the extension of a graphics filetype.)
Treating a binary file as if its text is not liable to work very well.
Also can you please confirm whether this task is homework/study related?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor