# # file: read-from-file2.py # This program opens a file "numbers.dat", reads all the information from it # and displays it on the screen. # !!! Please, note the the input file "numbers.dat" should be stored in the # same place your program is. # # The program uses readline() function # # This program is written 'bad' in the following sence: # it assumes that there are exactly two lines in the file def main(): in_stream=open("numbers.dat","r") # opening file "numbers.dat" string1=in_stream.readline() # reading first line string2=in_stream.readline() # reading second line print "The contents of the file %s is:" % ("numbers.dat") print string1[:-1] # [:-1] eliminated the last character, newline, to be # outputed to the screen. print string2 main()