<br><br><div class="gmail_quote">On Thu, Sep 29, 2011 at 11:18 PM, Walter Prins <span dir="ltr"><<a href="mailto:wprins@gmail.com">wprins@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br><div class="gmail_quote"><div class="im">On 29 September 2011 16:13, lina <span dir="ltr"><<a href="mailto:lina.lastname@gmail.com" target="_blank">lina.lastname@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>mport os.path<br><br>tokens=['E']<br>result=[]<br><br>for fileName in os.listdir("."):<br> if os.path.isfile(fileName) and os.path.splitext(fileName)=="xpm":<br></div> filedata = open(fileName,'r')<div>
<br>
text=filedata.readlines()<br> for line in text:<br></div> print line<br><br>why here I print nothing out?<br><br>There is .xpm file there with content.<br><br>Thanks,<div><div></div><br></div></blockquote>
</div><div><br>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. <br>
<br>Also can you please confirm whether this task is homework/study related?<br></div></div></blockquote><div><br>I have some awk script to achieve this. I can assure you it's not homework. LOL ... I have never attended some python course.<br>
sometimes it's hard for you to image how hard I persuade myself to use/think in python way, forget what is-already-relatively-easy-for-me-to-use bash script.<br><br>the xpm file an read, I just text<br><br>f=open('1.xpm','r')<br>
for line in f.readlines():<br> print line<br>f.close()<br> <br>I am google-ing how to get the line index, so will use those after 24.<br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="gmail_quote"><div><font color="#888888"><br>Walter<br><br><br></font></div></div>
<br>_______________________________________________<br>
Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Best Regards,<br><br>lina<br><br><br>