[Tutor] .txt file out put
Morne
Morne" <fromclay@maxitec.co.za
Fri, 13 Sep 2002 10:38:45 +0200
This is a multi-part message in MIME format.
------=_NextPart_000_0018_01C25B11.BC5BCE20
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi=20
Can you help me=20
I need the code to print out the info in any .txt file im using python =
2.2 with the IDLE (GUI)
import string
def getStuff(file):
info =3D open(file,'r')
infolines =3D info.readlines()
=20
avg =3D wordcount/len(infolines)
print"Average words per line %f" %(avg)
=20
file =3D raw_input("Enter filename:")
getStuff(file)
Thanx
=20
------=_NextPart_000_0018_01C25B11.BC5BCE20
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Can you help me </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I need the code to print out the info =
in any .txt=20
file im using python 2.2 with the IDLE (GUI)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>import string<BR>def =
getStuff(file):<BR> info=20
=3D open(file,'r')<BR> infolines =3D =
info.readlines()<BR> <BR> avg =3D=20
wordcount/len(infolines)<BR> =20
print"Average words per line %f" %(avg)<BR> <BR>file =3D=20
raw_input("Enter filename:")<BR>getStuff(file)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanx</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR> </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV></BODY></HTML>
------=_NextPart_000_0018_01C25B11.BC5BCE20--