Differences between revisions 1 and 2
Revision 1 as of 2010-11-08 11:25:32
Size: 156
Editor: anonymous
Comment:
Revision 2 as of 2010-11-15 13:27:22
Size: 870
Comment:
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
{{{#!python
#!/usr/bin/env python

fl = raw_input("If you want to scan the file L5058011_01120090712_MTL.txt , type L5 and press enter! \n if you wish to scan any other file, enter the complete filename!")

print"\n\n\n"

print "you entered ", fl


print"\n\n\n"


if fl=="L5":
    infile = open("L5058011_01120090712_MTL.txt","r")
else:
    infile = open(fl,"r")



text = infile.readlines()
strt = raw_input("line starting with? ")

print"\n\n\n"
print "you entered ", strt
print"\n\n\n"
print "the following lines begin with",strt

for line in text:
    line_stripped=line.strip()
    if line_stripped.startswith(strt)==True:
        print line

}}}

   1 #!/usr/bin/env python
   2 
   3 fl = raw_input("If you want to scan the file L5058011_01120090712_MTL.txt , type L5 and press enter!                         \n if you wish to scan any other file, enter the complete filename!")
   4 
   5 print"\n\n\n"
   6 
   7 print "you entered ", fl
   8 
   9 
  10 print"\n\n\n"
  11 
  12 
  13 if fl=="L5":
  14     infile = open("L5058011_01120090712_MTL.txt","r")
  15 else: 
  16     infile = open(fl,"r")
  17 
  18 
  19 
  20 text = infile.readlines()
  21 strt = raw_input("line starting with? ")
  22 
  23 print"\n\n\n"
  24 print "you entered ", strt
  25 print"\n\n\n"
  26 print "the following lines begin with",strt
  27 
  28 for line in text:
  29     line_stripped=line.strip()
  30     if line_stripped.startswith(strt)==True:
  31         print line  

LehreWiki: OpenSource2010/Lesson4/Solution1 (last edited 2010-11-15 13:27:22 by nikolauskoopmann)